From 46477a6c6fe4650209d9ab4790ccca1ab62b404c Mon Sep 17 00:00:00 2001 From: the Date: Sat, 20 May 2023 07:41:13 +0400 Subject: [PATCH] order status --- .../BusinessLogics/ReportLogic.cs | 6 -- .../Controllers/HomeController.cs | 41 ++++++++++- .../Views/Home/Index.cshtml | 18 ++++- .../BindingModels/SupplyBindingModel.cs | 2 +- .../ViewModels/SupplyViewModel.cs | 2 +- .../Models/ISupplyModel.cs | 2 +- .../ComputerShopDatabase.cs | 2 +- .../Models/Supply.cs | 2 +- .../Controllers/MainController.cs | 69 ++++++++++++++++++- 9 files changed, 127 insertions(+), 17 deletions(-) diff --git a/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/ReportLogic.cs b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/ReportLogic.cs index bae0b1b..515fd18 100644 --- a/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/ReportLogic.cs @@ -52,11 +52,6 @@ namespace ComputerShopBusinessLogic.BusinessLogics var receivings = new List(); - // ОШИБКА: int не содержит определения HasValue() - - - /* - foreach(var supply in supplies) { if (supply.ReceivingId.HasValue) @@ -69,7 +64,6 @@ namespace ComputerShopBusinessLogic.BusinessLogics } } - */ var receivingnames = new List(); foreach (var receiving in receivings) diff --git a/ComputerShopProvider/ComputerShopClientApp/Controllers/HomeController.cs b/ComputerShopProvider/ComputerShopClientApp/Controllers/HomeController.cs index 4444081..14e22da 100644 --- a/ComputerShopProvider/ComputerShopClientApp/Controllers/HomeController.cs +++ b/ComputerShopProvider/ComputerShopClientApp/Controllers/HomeController.cs @@ -2,8 +2,10 @@ using ComputerShopContracts.BindingModels; using ComputerShopContracts.SearchModels; using ComputerShopContracts.ViewModels; +using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Mvc; using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using System.ComponentModel; using System.Diagnostics; namespace ComputerShopClientApp.Controllers @@ -147,6 +149,12 @@ namespace ComputerShopClientApp.Controllers } } + [HttpGet] + public IActionResult Enter() + { + return View(); + } + [HttpGet] public IActionResult GetWordFile() { @@ -158,10 +166,37 @@ namespace ComputerShopClientApp.Controllers return new PhysicalFileResult("F:\\ReportsCourseWork\\excelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); } - [HttpGet] - public IActionResult Enter() + [HttpPost] + public void SetInWork(int id) { - return View(); + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + APIClient.PostRequest($"api/main/setinwork?id={id}", id); + Response.Redirect("Index"); + } + + [HttpPost] + public void SetReady(int id) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + APIClient.PostRequest($"api/main/setready?id={id}", id); + Response.Redirect("Index"); + } + + [HttpPost] + public void SetDone(int id) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + APIClient.PostRequest($"api/main/setdone?id={id}", id); + Response.Redirect("Index"); } [HttpPost] diff --git a/ComputerShopProvider/ComputerShopClientApp/Views/Home/Index.cshtml b/ComputerShopProvider/ComputerShopClientApp/Views/Home/Index.cshtml index 7358cc1..b7abad3 100644 --- a/ComputerShopProvider/ComputerShopClientApp/Views/Home/Index.cshtml +++ b/ComputerShopProvider/ComputerShopClientApp/Views/Home/Index.cshtml @@ -7,7 +7,7 @@ }
-

Заказы

+

Покупки

@@ -20,7 +20,7 @@ }

- Создать заказ + Создать покупку

@@ -67,6 +67,20 @@ + } diff --git a/ComputerShopProvider/ComputerShopContracts/BindingModels/SupplyBindingModel.cs b/ComputerShopProvider/ComputerShopContracts/BindingModels/SupplyBindingModel.cs index cbfa824..faf861b 100644 --- a/ComputerShopProvider/ComputerShopContracts/BindingModels/SupplyBindingModel.cs +++ b/ComputerShopProvider/ComputerShopContracts/BindingModels/SupplyBindingModel.cs @@ -11,7 +11,7 @@ namespace ComputerShopContracts.BindingModels public class SupplyBindingModel : ISupplyModel { public int Id { get; set; } - public int ReceivingId { get; set; } + public int? ReceivingId { get; set; } public SupplyStatus Status { get; set; } = SupplyStatus.Неизвестен; public DateTime DateCreate { get; set; } = DateTime.Now; diff --git a/ComputerShopProvider/ComputerShopContracts/ViewModels/SupplyViewModel.cs b/ComputerShopProvider/ComputerShopContracts/ViewModels/SupplyViewModel.cs index ed365cb..dada925 100644 --- a/ComputerShopProvider/ComputerShopContracts/ViewModels/SupplyViewModel.cs +++ b/ComputerShopProvider/ComputerShopContracts/ViewModels/SupplyViewModel.cs @@ -23,7 +23,7 @@ namespace ComputerShopContracts.ViewModels [DisplayName("Номер")] public int Id { get; set; } [DisplayName("Номер получения")] - public int ReceivingId { get; set; } + public int? ReceivingId { get; set; } public Dictionary SupplyOrders { get; diff --git a/ComputerShopProvider/ComputerShopDataModels/Models/ISupplyModel.cs b/ComputerShopProvider/ComputerShopDataModels/Models/ISupplyModel.cs index c159c15..cf958e3 100644 --- a/ComputerShopProvider/ComputerShopDataModels/Models/ISupplyModel.cs +++ b/ComputerShopProvider/ComputerShopDataModels/Models/ISupplyModel.cs @@ -7,7 +7,7 @@ namespace ComputerShopDataModels.Models SupplyStatus Status { get; } DateTime DateCreate { get; } DateTime? DateImplement { get; } - int ReceivingId { get; } + int? ReceivingId { get; } Dictionary SupplyOrders { get; } } } diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabase.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabase.cs index 75be136..69a127f 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabase.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabase.cs @@ -15,7 +15,7 @@ namespace ComputerShopDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-QA8P9OJ;Initial Catalog=ComputerShopDatabaseCW;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-IRUVF5S\SQLEXPRESS;Initial Catalog=ComputerShopDatabaseCW;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs index 101c724..3e38dae 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs @@ -25,7 +25,7 @@ namespace ComputerShopDatabaseImplement.Models public int OrderId { get; set; } - public int ReceivingId { get; set; } + public int? ReceivingId { get; set; } public virtual EquipmentReceiving Receiving { get; set; } private Dictionary? _supplyOrders = diff --git a/ComputerShopProvider/ComputerShopRestApi/Controllers/MainController.cs b/ComputerShopProvider/ComputerShopRestApi/Controllers/MainController.cs index 8aba156..e63ec59 100644 --- a/ComputerShopProvider/ComputerShopRestApi/Controllers/MainController.cs +++ b/ComputerShopProvider/ComputerShopRestApi/Controllers/MainController.cs @@ -1,7 +1,9 @@ using ComputerShopContracts.BindingModels; using ComputerShopContracts.BusinessLogicContracts; using ComputerShopContracts.SearchModels; +using ComputerShopContracts.StorageContracts; using ComputerShopContracts.ViewModels; +using DocumentFormat.OpenXml.Presentation; using Microsoft.AspNetCore.Mvc; namespace ComputerShopRestApi.Controllers @@ -12,12 +14,14 @@ namespace ComputerShopRestApi.Controllers { private readonly ILogger _logger; private readonly IPurchaseLogic _purchase; + private readonly IPurchaseStorage _purchaseSTR; private readonly IComponentLogic _component; - public MainController(ILogger logger, IPurchaseLogic purchase, IComponentLogic component) + public MainController(ILogger logger, IPurchaseLogic purchase, IComponentLogic component, IPurchaseStorage purchaseStorage) { _logger = logger; _purchase = purchase; _component = component; + _purchaseSTR = purchaseStorage; } [HttpGet] public List? GetComponentList() @@ -77,5 +81,68 @@ namespace ComputerShopRestApi.Controllers throw; } } + [HttpPost] + public void SetInWork(int id) + { + try + { + var puchase = _purchaseSTR.GetElement(new() { Id = id }); + _purchase.TakePurchaseInWork(new() + { + Id = id, + ComponentId = puchase.ComponentId, + Count = puchase.Count, + Sum = puchase.Sum, + Status = puchase.Status + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка изменения закупки"); + throw; + } + } + [HttpPost] + public void SetReady(int id) + { + try + { + var puchase = _purchaseSTR.GetElement(new() { Id = id }); + _purchase.FinishPurchase(new() + { + Id = id, + ComponentId = puchase.ComponentId, + Count = puchase.Count, + Sum = puchase.Sum, + Status = puchase.Status + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка изменения закупки"); + throw; + } + } + [HttpPost] + public void SetDone(int id) + { + try + { + var puchase = _purchaseSTR.GetElement(new() { Id = id }); + _purchase.DeliveryPurchase(new() + { + Id = id, + ComponentId = puchase.ComponentId, + Count = puchase.Count, + Sum = puchase.Sum, + Status = puchase.Status + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка изменения закупки"); + throw; + } + } } }
@Html.DisplayFor(modelItem => item.Status) +
+ + +
+
+ + +
+
+ + +
+