diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/DataBase.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/DataBase.cs index 23bfaec..e4868b2 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/DataBase.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/DataBase.cs @@ -12,7 +12,7 @@ namespace ElectronicsShopDataBaseImplement optionsBuilder) { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-O0N00SH\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-E2VPEN3\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs index 73a4d44..37d2866 100644 --- a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs +++ b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs @@ -103,20 +103,11 @@ namespace ElectronicsShopRestAPI.Controllers { { try { - if (_order.ReadElement(new OrderSearchModel { ID = model.ID })==null) - { - CreateOrder( new OrderBindingModel - { - ClientID = model.ClientID, - ProductList = model.ProductList,//Суда поступает пустой список - Sum = model.Sum - }); - } var order=_order.ReadElement(new OrderSearchModel { ID = model.ID });//возвращает null if (model != null&& order!=null) { order.ProductList = model.ProductList; - order.Sum = model.Sum; + order.Sum += model.Sum; } } catch (Exception ex) diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs index b845c73..49e1181 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs @@ -1,18 +1,22 @@ using ElectronicsShopContracts.BindingModels; +using ElectronicsShopContracts.BusinessLogicContracts; using ElectronicsShopContracts.SearchModels; using ElectronicsShopContracts.ViewModels; using ElectronicsShopDataModels.Models; using ElectronicsShopUserApp.Models; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; +using System.Reflection; using System.Runtime.Serialization; namespace ElectronicsShopUserApp.Controllers { public class HomeController : Controller { private readonly ILogger _logger; + //private readonly IOrderLogic _order; - public HomeController(ILogger logger) { + public HomeController(ILogger logger/*, IOrderLogic orderLogic*/) { _logger = logger; + //_order = orderLogic; } public IActionResult Index() { @@ -92,12 +96,13 @@ namespace ElectronicsShopUserApp.Controllers { } [HttpGet] - public IActionResult CreateOrder() { - ViewBag.Products = APIClient.GetRequset>("api/main/getproducts"); + public IActionResult CreateOrders() { + + ViewBag.Products =APIClient.GetRequset>("api/main/getproducts"); return View(); } [HttpPost] - public void CreateOrder(OrderBindingModel order) { + public void CreateOrders(OrderBindingModel order) { if (APIClient.Client == null) { throw new Exception(" ? "); @@ -122,7 +127,7 @@ namespace ElectronicsShopUserApp.Controllers { public double Calc(int count, int product) { var prod = - APIClient.GetRequset($"api/main/getproduct?productID={product}" + APIClient.GetRequset($"api/main/getproduct?_productid={product}" ); return count * (prod?.Price ?? 1); } @@ -133,7 +138,7 @@ namespace ElectronicsShopUserApp.Controllers { return View(); } [HttpPost] - public void AddProduct(int count) + public void AddProduct(int count/*, int product*/) { if (APIClient.Client == null) { @@ -143,11 +148,7 @@ namespace ElectronicsShopUserApp.Controllers { { throw new Exception(" 0"); } - APIClient.PostRequest("api/main/addproduct", new OrderSearchModel - { - ID = 1, - ClientID=APIClient.Client.ID, - }); + Response.Redirect("CreateOrder"); } } diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/AddProduct.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/AddProduct.cshtml index 777c895..5166693 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/AddProduct.cshtml +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/AddProduct.cshtml @@ -6,7 +6,7 @@
-
Product:
+
Продукты:
-
-
-

Корзина

@{ diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Index.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Index.cshtml index c53b781..5dd8627 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Index.cshtml +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Index.cshtml @@ -17,12 +17,9 @@

Авторизируйтесь

return; } -

- Создать заказ -

- @@ -32,7 +29,7 @@ - + @foreach (var item in Model) { diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Shared/_Layout.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Shared/_Layout.cshtml index 948b12e..f572c08 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Shared/_Layout.cshtml +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Shared/_Layout.cshtml @@ -31,6 +31,12 @@ + +
+
Номер заказа Сумма