diff --git a/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/ReportLogic.cs b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/ReportLogic.cs index c3cd0d7..bae0b1b 100644 --- a/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/ReportLogic.cs @@ -51,6 +51,12 @@ namespace ComputerShopBusinessLogic.BusinessLogics var receivings = new List(); + + // ОШИБКА: int не содержит определения HasValue() + + + /* + foreach(var supply in supplies) { if (supply.ReceivingId.HasValue) @@ -62,6 +68,9 @@ namespace ComputerShopBusinessLogic.BusinessLogics } } } + + */ + var receivingnames = new List(); foreach (var receiving in receivings) { diff --git a/ComputerShopProvider/ComputerShopContracts/SearchModels/OrderSearchModel.cs b/ComputerShopProvider/ComputerShopContracts/SearchModels/OrderSearchModel.cs index dbbf64d..8eae0a3 100644 --- a/ComputerShopProvider/ComputerShopContracts/SearchModels/OrderSearchModel.cs +++ b/ComputerShopProvider/ComputerShopContracts/SearchModels/OrderSearchModel.cs @@ -9,6 +9,7 @@ namespace ComputerShopContracts.SearchModels public class OrderSearchModel { public int? Id { get; set; } + public int? ClientId { get; set; } public DateTime? DateFrom { get; set; } public DateTime? DateTo { get; set; } } diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabase.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabase.cs index 69a127f..75be136 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-IRUVF5S\SQLEXPRESS;Initial Catalog=ComputerShopDatabaseCW;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-QA8P9OJ;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 d6a3c49..101c724 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs @@ -56,7 +56,6 @@ namespace ComputerShopDatabaseImplement.Models Status = model.Status, DateCreate = model.DateCreate, DateImplement = model.DateImplement, - Receiving = model.Receiving, Orders = model.SupplyOrders.Select(x => new SupplyOrder { diff --git a/ComputerShopProvider/ComputerShopRestApi/Controllers/EquipmentReceivingController.cs b/ComputerShopProvider/ComputerShopRestApi/Controllers/EquipmentReceivingController.cs new file mode 100644 index 0000000..ae36476 --- /dev/null +++ b/ComputerShopProvider/ComputerShopRestApi/Controllers/EquipmentReceivingController.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace ComputerShopRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class EquipmentReceivingController : Controller + { + + } +} diff --git a/ComputerShopProvider/ComputerShopRestApi/Controllers/OrderController.cs b/ComputerShopProvider/ComputerShopRestApi/Controllers/OrderController.cs index a80bf5c..fbff0dc 100644 --- a/ComputerShopProvider/ComputerShopRestApi/Controllers/OrderController.cs +++ b/ComputerShopProvider/ComputerShopRestApi/Controllers/OrderController.cs @@ -7,43 +7,45 @@ using Microsoft.AspNetCore.Mvc; namespace ComputerShopRestApi.Controllers { + [Route("api/[controller]/[action]")] + [ApiController] public class OrderController : Controller { private readonly ILogger _logger; - private readonly IOrderLogic order; - private readonly IComponentLogic component; + private readonly IOrderLogic _order; + private readonly ISupplyLogic _supply; - public OrderController(ILogger logger, IOrderLogic order, IComponentLogic component) + public OrderController(ILogger logger, IOrderLogic order, ISupplyLogic supply) { _logger = logger; - order = order; - component = component; + _order = order; + _supply = supply; } [HttpGet] - public List? GetComponentList() + public List? GetOrderList(int clientId) { + try { - return component.ReadList(null); + return _order.ReadList(new OrderSearchModel { ClientId = clientId }); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получения списка комплектующих"); + _logger.LogError(ex, "Ошибка получения списка заказов"); throw; } } - [HttpGet] - public ComponentViewModel? GetPackage(int componentId) + public List? GetSuppliesList() { try { - return component.ReadElement(new ComponentSearchModel { Id = componentId }); + return _supply.ReadList(null); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получения продукта по id={Id}", componentId); + _logger.LogError(ex, "Ошибка получения списка компонентов"); throw; } } @@ -53,7 +55,7 @@ namespace ComputerShopRestApi.Controllers { try { - return order.ReadList(new OrderSearchModel {}); + return _order.ReadList(new OrderSearchModel {}); } catch (Exception ex) { @@ -67,7 +69,7 @@ namespace ComputerShopRestApi.Controllers { try { - order.CreateOrder(model); + _order.CreateOrder(model); } catch (Exception ex) { @@ -75,5 +77,18 @@ namespace ComputerShopRestApi.Controllers throw; } } + [HttpDelete] + public void DeleteOrder(OrderBindingModel model) + { + try + { + _order.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при удалении заказа"); + throw; + } + } } } diff --git a/ComputerShopProvider/ComputerShopRestApi/Controllers/SupplyController.cs b/ComputerShopProvider/ComputerShopRestApi/Controllers/SupplyController.cs new file mode 100644 index 0000000..96c6c81 --- /dev/null +++ b/ComputerShopProvider/ComputerShopRestApi/Controllers/SupplyController.cs @@ -0,0 +1,131 @@ +using ComputerShopContracts.BindingModels; +using ComputerShopContracts.BusinessLogicContracts; +using ComputerShopContracts.SearchModels; +using ComputerShopContracts.ViewModels; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace ComputerShopRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class SupplyController : Controller + { + private readonly ILogger _logger; + private readonly ISupplyLogic _supply; + private readonly IOrderLogic _order; + public SupplyController(ILogger logger, ISupplyLogic supply, IOrderLogic order) + { + _logger = logger; + _supply = supply; + _order = order; + } + + /* + + [HttpGet] + public List? GetAssemblyList(int clientId) + { + try + { + return _supply.ReadList(new SupplySearchModel + { + + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка сборок"); + throw; + } + } + + [HttpGet] + public Tuple>>? GetAssembly(int assemblyId) + { + try + { + var elem = _supply.ReadElement(new SupplySearchModel { Id = assemblyId }); + if (elem == null) + return null; + return Tuple.Create(elem, elem.AssemblyComponents.Select(x => Tuple.Create(x.Value.Item1.ComponentName, x.Value.Item2)).ToList()); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения сборки по id={Id}", assemblyId); + throw; + } + } + + [HttpGet] + public List? GetComponentList() + { + try + { + return _component.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка компонентов"); + throw; + } + } + [HttpPost] + public void CreateAssembly(AssemblyBindingModel model) + { + try + { + _assembly.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания сборки"); + throw; + } + } + [HttpPost] + public void DeleteAssembly(AssemblyBindingModel model) + { + try + { + _assembly.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления сборки"); + throw; + } + } + + [HttpPost] + public void AddComponentToAssembly(Tuple model) + { + try + { + _assembly.AddComponentToAssembly(model.Item1, model.Item2, model.Item3); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка добавления компонента в сборку."); + throw; + } + } + + [HttpPost] + public void EditAssembly(AssemblyBindingModel model) + { + try + { + _assembly.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления сборки"); + throw; + } + } + + */ + + } +}