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/ViewModels/SupplyViewModel.cs b/ComputerShopProvider/ComputerShopContracts/ViewModels/SupplyViewModel.cs index 62a7a4f..b2e89a7 100644 --- a/ComputerShopProvider/ComputerShopContracts/ViewModels/SupplyViewModel.cs +++ b/ComputerShopProvider/ComputerShopContracts/ViewModels/SupplyViewModel.cs @@ -26,7 +26,7 @@ namespace ComputerShopContracts.ViewModels [DisplayName("Номер клиента")] public int ClientId { 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 40461cc..85c9cb5 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs @@ -26,8 +26,8 @@ namespace ComputerShopDatabaseImplement.Models public int OrderId { get; set; } public int ClientId { get; set; } - public int ReceivingId { get; set; } - public virtual EquipmentReceiving? Receiving { get; set; } + public int? ReceivingId { get; set; } + public virtual EquipmentReceiving Receiving { get; set; } private Dictionary? _supplyOrders = null; 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) +
+ + +
+
+ + +
+
+ + +
+