forked from codehub-learn/Ms-App-Crm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
390 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Crm_Core.Options; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
using ModelCrm.Models; | ||
using ModelCrm.Services; | ||
using Ms_App_Crm.Models; | ||
|
||
namespace Ms_App_Crm.Controllers | ||
{ | ||
|
||
|
||
public class CartController : Controller | ||
{ | ||
|
||
private readonly ILogger<CartController> _logger; | ||
private readonly ICustomerService customerService; | ||
private readonly IProductService productService; | ||
private readonly IOrderService orderService; | ||
|
||
public CartController(ILogger<CartController> logger, ICustomerService _customerService, | ||
IProductService _productService, IOrderService _orderService) | ||
{ | ||
_logger = logger; | ||
customerService = _customerService; | ||
productService = _productService; | ||
orderService = _orderService; | ||
} | ||
|
||
public IActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
|
||
public IActionResult CreateOrder() | ||
{ | ||
int customerId = 15; | ||
|
||
OrderOption orderOption = orderService.CreateOrder(customerId); | ||
|
||
int orderId = orderOption.OrderId; | ||
|
||
List<ProductOptions> productsOpts = productService.GetAllProduct(); | ||
OrderModel productModel = new OrderModel | ||
{ | ||
products = productsOpts, | ||
orderId = orderId | ||
}; | ||
return View(productModel); | ||
} | ||
|
||
public IActionResult ViewOrders() | ||
{ | ||
|
||
AllOrdersModel allOrdersModel = new AllOrdersModel(); | ||
//to do | ||
//get all orders from order service | ||
|
||
return View(allOrdersModel); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Ms_App_Crm.Models | ||
{ | ||
|
||
public class AnOrderModel | ||
{ | ||
public int OrderId { get; set; } | ||
public string CustomerName { get; set; } | ||
public int CustomerId { get; set; } | ||
public DateTime Date { get; set; } | ||
} | ||
|
||
public class AllOrdersModel | ||
{ | ||
public List<AnOrderModel> orders { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,6 @@ namespace Ms_App_Crm.Models | |
public class ProductModel | ||
{ | ||
public List<ProductOptions> products { get; set; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@model OrderModel | ||
@{ | ||
ViewData["Title"] = "CreateOrder"; | ||
Layout = "~/Views/Shared/_OrdrerLayout.cshtml"; | ||
} | ||
|
||
<h1>CreateOrder</h1> | ||
|
||
|
||
|
||
<h2> Available products</h2> | ||
<table border="1" cellpadding="10" cellspacing="0"> | ||
<tr> | ||
<th> product Name </th> | ||
<th> product Description </th> | ||
<th> product Price </th> | ||
</tr> | ||
|
||
@{ | ||
foreach (var product in Model.products) | ||
{ | ||
<tr> | ||
<td><a href="#" onclick="buyProduct(@Model.orderId, @product.Id)">@product.Name</a> </td> | ||
<td> @product.Description </td> | ||
<td> @product.Price </td> | ||
</tr> | ||
} | ||
} | ||
|
||
</table> | ||
|
||
|
||
<h2> My cart</h2> | ||
<table id="myCart"> | ||
|
||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
@{ | ||
ViewData["Title"] = "Index"; | ||
Layout = "~/Views/Shared/_OrdrerLayout.cshtml"; | ||
} | ||
|
||
<h1>Index</h1> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
@model AllOrdersModel | ||
@{ | ||
ViewData["Title"] = "ViewOrders"; | ||
Layout = "~/Views/Shared/_OrdrerLayout.cshtml"; | ||
} | ||
|
||
<h1>ViewOrders</h1> | ||
|
||
<table id="ordersTable" border="1" cellpadding="10" cellspacing="0"> | ||
<tr> | ||
<th> Order Id</th> | ||
<th> Customer Name</th> | ||
<th> Customer Id</th> | ||
<th> Date</th> | ||
|
||
</tr> | ||
|
||
@{ | ||
foreach (var order in Model.orders) | ||
{ | ||
<tr> | ||
<td> @order.OrderId</td> | ||
<td> @order.CustomerName</td> | ||
<td> @order.CustomerId</td> | ||
<td> @order.Date</td> | ||
</tr> | ||
|
||
} | ||
} | ||
|
||
|
||
</table> |
Oops, something went wrong.