From c6c2d44702baa0bf84f89252a1cf2ae5bd91b9b9 Mon Sep 17 00:00:00 2001 From: the Date: Wed, 5 Apr 2023 18:31:49 +0400 Subject: [PATCH] Init create --- .../BusinessLogics/AssemblyLogic.cs | 119 +++++++++++++++++ .../BusinessLogics/ComponentLogic.cs | 114 +++++++++++++++++ .../BusinessLogics/PurchaseLogic.cs | 117 +++++++++++++++++ .../ComputerShopBusinessLogic.csproj | 13 ++ .../BindingModels/AssemblyBindingModel.cs | 21 +++ .../BindingModels/ComponentBindingModel.cs | 16 +++ .../BindingModels/PurchaseBindingModel.cs | 22 ++++ .../BusinessLogicContracts/IAssemblyLogic.cs | 20 +++ .../BusinessLogicContracts/IComponentLogic.cs | 20 +++ .../BusinessLogicContracts/IPurchaseLogic.cs | 20 +++ .../ComputerShopContracts.csproj | 13 ++ .../SearchModels/AssemblySearchModel.cs | 14 ++ .../SearchModels/ComponentSearchModel.cs | 14 ++ .../SearchModels/PurchaseSearchModel.cs | 15 +++ .../StorageContracts/IAssemblyStorage.cs | 21 +++ .../StorageContracts/IComponentStorage.cs | 21 +++ .../StorageContracts/IPurchaseStorage.cs | 21 +++ .../ViewModels/AssemblyViewModel.cs | 24 ++++ .../ViewModels/ComponentViewModel.cs | 19 +++ .../ViewModels/PurchaseViewModel.cs | 31 +++++ .../ComputerShopDataModels.csproj | 9 ++ .../Enums/PurchaseStatus.cs | 17 +++ .../ComputerShopDataModels/IId.cs | 13 ++ .../Models/IAssemblyModel.cs | 15 +++ .../Models/IComponentModel.cs | 14 ++ .../Models/IPurchaseModel.cs | 20 +++ .../ComputerShopDatabaseImplement.csproj | 9 ++ .../ComputerShopView/ComputerShopView.csproj | 11 ++ .../ComputerShopView/ComputerShopView.sln | 49 +++++++ .../ComputerShopView/Form1.Designer.cs | 39 ++++++ .../ComputerShopView/Form1.cs | 10 ++ .../ComputerShopView/Form1.resx | 120 ++++++++++++++++++ .../ComputerShopView/Program.cs | 17 +++ 33 files changed, 1018 insertions(+) create mode 100644 ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/AssemblyLogic.cs create mode 100644 ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/ComponentLogic.cs create mode 100644 ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/PurchaseLogic.cs create mode 100644 ComputerShopProvider/ComputerShopBusinessLogic/ComputerShopBusinessLogic.csproj create mode 100644 ComputerShopProvider/ComputerShopContracts/BindingModels/AssemblyBindingModel.cs create mode 100644 ComputerShopProvider/ComputerShopContracts/BindingModels/ComponentBindingModel.cs create mode 100644 ComputerShopProvider/ComputerShopContracts/BindingModels/PurchaseBindingModel.cs create mode 100644 ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IAssemblyLogic.cs create mode 100644 ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IComponentLogic.cs create mode 100644 ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IPurchaseLogic.cs create mode 100644 ComputerShopProvider/ComputerShopContracts/ComputerShopContracts.csproj create mode 100644 ComputerShopProvider/ComputerShopContracts/SearchModels/AssemblySearchModel.cs create mode 100644 ComputerShopProvider/ComputerShopContracts/SearchModels/ComponentSearchModel.cs create mode 100644 ComputerShopProvider/ComputerShopContracts/SearchModels/PurchaseSearchModel.cs create mode 100644 ComputerShopProvider/ComputerShopContracts/StorageContracts/IAssemblyStorage.cs create mode 100644 ComputerShopProvider/ComputerShopContracts/StorageContracts/IComponentStorage.cs create mode 100644 ComputerShopProvider/ComputerShopContracts/StorageContracts/IPurchaseStorage.cs create mode 100644 ComputerShopProvider/ComputerShopContracts/ViewModels/AssemblyViewModel.cs create mode 100644 ComputerShopProvider/ComputerShopContracts/ViewModels/ComponentViewModel.cs create mode 100644 ComputerShopProvider/ComputerShopContracts/ViewModels/PurchaseViewModel.cs create mode 100644 ComputerShopProvider/ComputerShopDataModels/ComputerShopDataModels.csproj create mode 100644 ComputerShopProvider/ComputerShopDataModels/Enums/PurchaseStatus.cs create mode 100644 ComputerShopProvider/ComputerShopDataModels/IId.cs create mode 100644 ComputerShopProvider/ComputerShopDataModels/Models/IAssemblyModel.cs create mode 100644 ComputerShopProvider/ComputerShopDataModels/Models/IComponentModel.cs create mode 100644 ComputerShopProvider/ComputerShopDataModels/Models/IPurchaseModel.cs create mode 100644 ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabaseImplement.csproj create mode 100644 ComputerShopProvider/ComputerShopView/ComputerShopView.csproj create mode 100644 ComputerShopProvider/ComputerShopView/ComputerShopView.sln create mode 100644 ComputerShopProvider/ComputerShopView/Form1.Designer.cs create mode 100644 ComputerShopProvider/ComputerShopView/Form1.cs create mode 100644 ComputerShopProvider/ComputerShopView/Form1.resx create mode 100644 ComputerShopProvider/ComputerShopView/Program.cs diff --git a/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/AssemblyLogic.cs b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/AssemblyLogic.cs new file mode 100644 index 0000000..f6d776a --- /dev/null +++ b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/AssemblyLogic.cs @@ -0,0 +1,119 @@ +using ComputerShopContracts.BindingModels; +using ComputerShopContracts.BusinessLogicContracts; +using ComputerShopContracts.SearchModels; +using ComputerShopContracts.StorageContracts; +using ComputerShopContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopBusinessLogic.BusinessLogics +{ + public class AssemblyLogic : IAssemblyLogic + { + private readonly ILogger _logger; + private readonly IAssemblyStorage _assemblyStorage; + + public AssemblyLogic(ILogger logger, IAssemblyStorage assemblyStorage) + { + _logger = logger; + _assemblyStorage = assemblyStorage; + } + + public bool Create(AssemblyBindingModel model) + { + CheckModel(model); + if (_assemblyStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Delete(AssemblyBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_assemblyStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + public AssemblyViewModel? ReadElement(AssemblySearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. AssemblyName:{AssemblyName}.Id:{ Id}", model.AssemblyName, model.Id); + var element = _assemblyStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + + public List? ReadList(AssemblySearchModel? model) + { + _logger.LogInformation("ReadList. AssemblyName:{AssemblyName}.Id:{ Id}", model?.AssemblyName, model?.Id); + var list = model == null ? _assemblyStorage.GetFullList() : _assemblyStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + public bool Update(AssemblyBindingModel model) + { + CheckModel(model); + if (_assemblyStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + private void CheckModel(AssemblyBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.AssemblyName)) + { + throw new ArgumentNullException("Нет названия сборки", nameof(model.AssemblyName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Стоимость сборки должна быть больше 0", nameof(model.Price)); + } + _logger.LogInformation("Assembly. ComputerName:{AssemblyName}.Price:{ Price}. Id: { Id}", model.AssemblyName, model.Price, model.Id); + var element = _assemblyStorage.GetElement(new AssemblySearchModel + { + AssemblyName = model.AssemblyName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Сборка с таким названием уже есть"); + } + } + } +} diff --git a/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/ComponentLogic.cs b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/ComponentLogic.cs new file mode 100644 index 0000000..664144e --- /dev/null +++ b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/ComponentLogic.cs @@ -0,0 +1,114 @@ +using ComputerShopContracts.BindingModels; +using ComputerShopContracts.BusinessLogicContracts; +using ComputerShopContracts.SearchModels; +using ComputerShopContracts.StorageContracts; +using ComputerShopContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopBusinessLogic.BusinessLogics +{ + public class ComponentLogic : IComponentLogic + { + private readonly ILogger _logger; + private readonly IComponentStorage _componentStorage; + public ComponentLogic(ILogger logger, IComponentStorage componentStorage) + { + _logger = logger; + _componentStorage = componentStorage; + } + public List? ReadList(ComponentSearchModel? model) + { + _logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{ Id}", model?.ComponentName, model?.Id); + var list = model == null ? _componentStorage.GetFullList() : + _componentStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public ComponentViewModel? ReadElement(ComponentSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{ Id}", model.ComponentName, model.Id); + var element = _componentStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ComponentBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_componentStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(ComponentBindingModel model, bool withParams = + true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ComponentName)) + { + throw new ArgumentNullException("Нет названия компонента", nameof(model.ComponentName)); + } + if (model.Cost <= 0) + { + throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost)); + } + _logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{ Cost}. Id: { Id} ", model.ComponentName, model.Cost, model.Id); + var element = _componentStorage.GetElement(new ComponentSearchModel + { + ComponentName = model.ComponentName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} diff --git a/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/PurchaseLogic.cs b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/PurchaseLogic.cs new file mode 100644 index 0000000..3719e11 --- /dev/null +++ b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/PurchaseLogic.cs @@ -0,0 +1,117 @@ +using ComputerShopContracts.BindingModels; +using ComputerShopContracts.BusinessLogicContracts; +using ComputerShopContracts.SearchModels; +using ComputerShopContracts.StorageContracts; +using ComputerShopContracts.ViewModels; +using ComputerShopDataModels.Enums; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopBusinessLogic.BusinessLogics +{ + public class PurchaseLogic : IPurchaseLogic + { + private readonly ILogger _logger; + private readonly IPurchaseStorage _purchaseStorage; + + public PurchaseLogic(ILogger logger, IPurchaseStorage purchaseStorage) + { + _logger = logger; + _purchaseStorage = purchaseStorage; + } + + public bool CreateOrder(PurchaseBindingModel model) + { + CheckModel(model); + if (model.Status != PurchaseStatus.Неизвестен) + { + _logger.LogWarning("Insert operation failed. Purchase status incorrect."); + return false; + } + model.Status = PurchaseStatus.Принят; + if (_purchaseStorage.Insert(model) == null) + { + model.Status = PurchaseStatus.Неизвестен; + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool StatusUpdate(PurchaseBindingModel model, PurchaseStatus newStatus) + { + CheckModel(model); + if (model.Status + 1 != newStatus) + { + _logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect."); + return false; + } + model.Status = newStatus; + if (model.Status == PurchaseStatus.Выдан) model.DateImplement = DateTime.Now; + if (_purchaseStorage.Update(model) == null) + { + model.Status--; + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + public bool TakeOrderInWork(PurchaseBindingModel model) + { + return StatusUpdate(model, PurchaseStatus.Выполняется); + } + + public bool DeliveryOrder(PurchaseBindingModel model) + { + return StatusUpdate(model, PurchaseStatus.Готов); + } + + public bool FinishOrder(PurchaseBindingModel model) + { + return StatusUpdate(model, PurchaseStatus.Выдан); + } + + public List? ReadList(PurchaseSearchModel? model) + { + _logger.LogInformation("Order. OrderID:{Id}", model?.Id); + var list = model == null ? _purchaseStorage.GetFullList() : _purchaseStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + private void CheckModel(PurchaseBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.ComponentId < 0) + { + throw new ArgumentNullException("Некорректный идентификатор компонента", nameof(model.ComponentId)); + } + if (model.Count <= 0) + { + throw new ArgumentNullException("Количество компонентов в заказе должно быть больше 0", nameof(model.Count)); + } + if (model.Sum <= 0) + { + throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum)); + } + _logger.LogInformation("Order. OrderID:{Id}.Sum:{ Sum}. ComponentId: { ComponentId}", model.Id, model.Sum, model.ComponentId); + } + } +} diff --git a/ComputerShopProvider/ComputerShopBusinessLogic/ComputerShopBusinessLogic.csproj b/ComputerShopProvider/ComputerShopBusinessLogic/ComputerShopBusinessLogic.csproj new file mode 100644 index 0000000..63a55ef --- /dev/null +++ b/ComputerShopProvider/ComputerShopBusinessLogic/ComputerShopBusinessLogic.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/ComputerShopProvider/ComputerShopContracts/BindingModels/AssemblyBindingModel.cs b/ComputerShopProvider/ComputerShopContracts/BindingModels/AssemblyBindingModel.cs new file mode 100644 index 0000000..500b2c8 --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/BindingModels/AssemblyBindingModel.cs @@ -0,0 +1,21 @@ +using ComputerShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.BindingModels +{ + public class AssemblyBindingModel : IAssemblyModel + { + public int Id { get; set; } + public string AssemblyName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary AssemblyComponents + { + get; + set; + } = new(); + } +} diff --git a/ComputerShopProvider/ComputerShopContracts/BindingModels/ComponentBindingModel.cs b/ComputerShopProvider/ComputerShopContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..fee5e4d --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,16 @@ +using ComputerShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.BindingModels +{ + public class ComponentBindingModel : IComponentModel + { + public int Id { get; set; } + public string ComponentName { get; set; } = string.Empty; + public double Cost { get; set; } + } +} diff --git a/ComputerShopProvider/ComputerShopContracts/BindingModels/PurchaseBindingModel.cs b/ComputerShopProvider/ComputerShopContracts/BindingModels/PurchaseBindingModel.cs new file mode 100644 index 0000000..178b315 --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/BindingModels/PurchaseBindingModel.cs @@ -0,0 +1,22 @@ +using ComputerShopDataModels.Enums; +using ComputerShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.BindingModels +{ + public class PurchaseBindingModel : IPurchaseModel + { + public int Id { get; set; } + public int ComponentId { get; set; } + public string ComponentName { get; set; } = string.Empty; + public int Count { get; set; } + public double Sum { get; set; } + public PurchaseStatus Status { get; set; } = PurchaseStatus.Неизвестен; + public DateTime DateCreate { get; set; } = DateTime.Now; + public DateTime? DateImplement { get; set; } + } +} diff --git a/ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IAssemblyLogic.cs b/ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IAssemblyLogic.cs new file mode 100644 index 0000000..f346b5c --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IAssemblyLogic.cs @@ -0,0 +1,20 @@ +using ComputerShopContracts.BindingModels; +using ComputerShopContracts.SearchModels; +using ComputerShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.BusinessLogicContracts +{ + public interface IAssemblyLogic + { + List? ReadList(AssemblySearchModel? model); + AssemblyViewModel? ReadElement(AssemblySearchModel model); + bool Create(AssemblyBindingModel model); + bool Update(AssemblyBindingModel model); + bool Delete(AssemblyBindingModel model); + } +} diff --git a/ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IComponentLogic.cs b/ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IComponentLogic.cs new file mode 100644 index 0000000..6e013d9 --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IComponentLogic.cs @@ -0,0 +1,20 @@ +using ComputerShopContracts.BindingModels; +using ComputerShopContracts.SearchModels; +using ComputerShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.BusinessLogicContracts +{ + public interface IComponentLogic + { + List? ReadList(ComponentSearchModel? model); + ComponentViewModel? ReadElement(ComponentSearchModel model); + bool Create(ComponentBindingModel model); + bool Update(ComponentBindingModel model); + bool Delete(ComponentBindingModel model); + } +} diff --git a/ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IPurchaseLogic.cs b/ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IPurchaseLogic.cs new file mode 100644 index 0000000..98b3019 --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IPurchaseLogic.cs @@ -0,0 +1,20 @@ +using ComputerShopContracts.BindingModels; +using ComputerShopContracts.SearchModels; +using ComputerShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.BusinessLogicContracts +{ + public interface IPurchaseLogic + { + List? ReadList(PurchaseSearchModel? model); + bool CreateOrder(PurchaseBindingModel model); + bool TakeOrderInWork(PurchaseBindingModel model); + bool FinishOrder(PurchaseBindingModel model); + bool DeliveryOrder(PurchaseBindingModel model); + } +} diff --git a/ComputerShopProvider/ComputerShopContracts/ComputerShopContracts.csproj b/ComputerShopProvider/ComputerShopContracts/ComputerShopContracts.csproj new file mode 100644 index 0000000..44886d9 --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/ComputerShopContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/ComputerShopProvider/ComputerShopContracts/SearchModels/AssemblySearchModel.cs b/ComputerShopProvider/ComputerShopContracts/SearchModels/AssemblySearchModel.cs new file mode 100644 index 0000000..120c88d --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/SearchModels/AssemblySearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.SearchModels +{ + public class AssemblySearchModel + { + public int? Id { get; set; } + public string? AssemblyName { get; set; } + } +} diff --git a/ComputerShopProvider/ComputerShopContracts/SearchModels/ComponentSearchModel.cs b/ComputerShopProvider/ComputerShopContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..78421a7 --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } +} diff --git a/ComputerShopProvider/ComputerShopContracts/SearchModels/PurchaseSearchModel.cs b/ComputerShopProvider/ComputerShopContracts/SearchModels/PurchaseSearchModel.cs new file mode 100644 index 0000000..d2f821f --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/SearchModels/PurchaseSearchModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.SearchModels +{ + public class PurchaseSearchModel + { + public int? Id { get; set; } + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } + } +} diff --git a/ComputerShopProvider/ComputerShopContracts/StorageContracts/IAssemblyStorage.cs b/ComputerShopProvider/ComputerShopContracts/StorageContracts/IAssemblyStorage.cs new file mode 100644 index 0000000..0fa8609 --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/StorageContracts/IAssemblyStorage.cs @@ -0,0 +1,21 @@ +using ComputerShopContracts.BindingModels; +using ComputerShopContracts.SearchModels; +using ComputerShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.StorageContracts +{ + public interface IAssemblyStorage + { + List GetFullList(); + List GetFilteredList(AssemblySearchModel model); + AssemblyViewModel? GetElement(AssemblySearchModel model); + AssemblyViewModel? Insert(AssemblyBindingModel model); + AssemblyViewModel? Update(AssemblyBindingModel model); + AssemblyViewModel? Delete(AssemblyBindingModel model); + } +} diff --git a/ComputerShopProvider/ComputerShopContracts/StorageContracts/IComponentStorage.cs b/ComputerShopProvider/ComputerShopContracts/StorageContracts/IComponentStorage.cs new file mode 100644 index 0000000..959317c --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/StorageContracts/IComponentStorage.cs @@ -0,0 +1,21 @@ +using ComputerShopContracts.BindingModels; +using ComputerShopContracts.SearchModels; +using ComputerShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.StorageContracts +{ + public interface IComponentStorage + { + List GetFullList(); + List GetFilteredList(ComponentSearchModel model); + ComponentViewModel? GetElement(ComponentSearchModel model); + ComponentViewModel? Insert(ComponentBindingModel model); + ComponentViewModel? Update(ComponentBindingModel model); + ComponentViewModel? Delete(ComponentBindingModel model); + } +} diff --git a/ComputerShopProvider/ComputerShopContracts/StorageContracts/IPurchaseStorage.cs b/ComputerShopProvider/ComputerShopContracts/StorageContracts/IPurchaseStorage.cs new file mode 100644 index 0000000..b4a0b0c --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/StorageContracts/IPurchaseStorage.cs @@ -0,0 +1,21 @@ +using ComputerShopContracts.BindingModels; +using ComputerShopContracts.SearchModels; +using ComputerShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.StorageContracts +{ + public interface IPurchaseStorage + { + List GetFullList(); + List GetFilteredList(PurchaseSearchModel model); + PurchaseViewModel? GetElement(PurchaseSearchModel model); + PurchaseViewModel? Insert(PurchaseBindingModel model); + PurchaseViewModel? Update(PurchaseBindingModel model); + PurchaseViewModel? Delete(PurchaseBindingModel model); + } +} diff --git a/ComputerShopProvider/ComputerShopContracts/ViewModels/AssemblyViewModel.cs b/ComputerShopProvider/ComputerShopContracts/ViewModels/AssemblyViewModel.cs new file mode 100644 index 0000000..ea2a108 --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/ViewModels/AssemblyViewModel.cs @@ -0,0 +1,24 @@ +using ComputerShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.ViewModels +{ + public class AssemblyViewModel : IAssemblyModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string AssemblyName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary AssemblyComponents + { + get; + set; + } = new(); + } +} diff --git a/ComputerShopProvider/ComputerShopContracts/ViewModels/ComponentViewModel.cs b/ComputerShopProvider/ComputerShopContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..661912e --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,19 @@ +using ComputerShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.ViewModels +{ + public class ComponentViewModel : IComponentModel + { + public int Id { get; set; } + [DisplayName("Название компонента")] + public string ComponentName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Cost { get; set; } + } +} diff --git a/ComputerShopProvider/ComputerShopContracts/ViewModels/PurchaseViewModel.cs b/ComputerShopProvider/ComputerShopContracts/ViewModels/PurchaseViewModel.cs new file mode 100644 index 0000000..c76be90 --- /dev/null +++ b/ComputerShopProvider/ComputerShopContracts/ViewModels/PurchaseViewModel.cs @@ -0,0 +1,31 @@ +using ComputerShopDataModels.Enums; +using ComputerShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.ViewModels +{ + public class PurchaseViewModel : IPurchaseModel + { + public int ComponentId { get; set; } + + [DisplayName("Номер")] + public int Id { get; set; } + [DisplayName("Компонент")] + public string ComponentName { get; set; } = string.Empty; + [DisplayName("Количество")] + public int Count { get; set; } + [DisplayName("Сумма")] + public double Sum { get; set; } + [DisplayName("Статус")] + public PurchaseStatus Status { get; set; } = PurchaseStatus.Неизвестен; + [DisplayName("Дата создания")] + public DateTime DateCreate { get; set; } = DateTime.Now; + [DisplayName("Дата выполнения")] + public DateTime? DateImplement { get; set; } + } +} diff --git a/ComputerShopProvider/ComputerShopDataModels/ComputerShopDataModels.csproj b/ComputerShopProvider/ComputerShopDataModels/ComputerShopDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/ComputerShopProvider/ComputerShopDataModels/ComputerShopDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/ComputerShopProvider/ComputerShopDataModels/Enums/PurchaseStatus.cs b/ComputerShopProvider/ComputerShopDataModels/Enums/PurchaseStatus.cs new file mode 100644 index 0000000..e6e1d91 --- /dev/null +++ b/ComputerShopProvider/ComputerShopDataModels/Enums/PurchaseStatus.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopDataModels.Enums +{ + public enum PurchaseStatus + { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 + } +} diff --git a/ComputerShopProvider/ComputerShopDataModels/IId.cs b/ComputerShopProvider/ComputerShopDataModels/IId.cs new file mode 100644 index 0000000..9e47f98 --- /dev/null +++ b/ComputerShopProvider/ComputerShopDataModels/IId.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/ComputerShopProvider/ComputerShopDataModels/Models/IAssemblyModel.cs b/ComputerShopProvider/ComputerShopDataModels/Models/IAssemblyModel.cs new file mode 100644 index 0000000..4d5afd3 --- /dev/null +++ b/ComputerShopProvider/ComputerShopDataModels/Models/IAssemblyModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopDataModels.Models +{ + public interface IAssemblyModel : IId + { + string AssemblyName { get; } + double Price { get; } + Dictionary AssemblyComponents { get; } + } +} diff --git a/ComputerShopProvider/ComputerShopDataModels/Models/IComponentModel.cs b/ComputerShopProvider/ComputerShopDataModels/Models/IComponentModel.cs new file mode 100644 index 0000000..a4116ac --- /dev/null +++ b/ComputerShopProvider/ComputerShopDataModels/Models/IComponentModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + double Cost { get; } + } +} diff --git a/ComputerShopProvider/ComputerShopDataModels/Models/IPurchaseModel.cs b/ComputerShopProvider/ComputerShopDataModels/Models/IPurchaseModel.cs new file mode 100644 index 0000000..04741da --- /dev/null +++ b/ComputerShopProvider/ComputerShopDataModels/Models/IPurchaseModel.cs @@ -0,0 +1,20 @@ +using ComputerShopDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopDataModels.Models +{ + public interface IPurchaseModel : IId + { + int ComponentId { get; } + string ComponentName { get; } + int Count { get; } + double Sum { get; } + PurchaseStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get; } + } +} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabaseImplement.csproj b/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabaseImplement.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabaseImplement.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/ComputerShopProvider/ComputerShopView/ComputerShopView.csproj b/ComputerShopProvider/ComputerShopView/ComputerShopView.csproj new file mode 100644 index 0000000..b57c89e --- /dev/null +++ b/ComputerShopProvider/ComputerShopView/ComputerShopView.csproj @@ -0,0 +1,11 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + \ No newline at end of file diff --git a/ComputerShopProvider/ComputerShopView/ComputerShopView.sln b/ComputerShopProvider/ComputerShopView/ComputerShopView.sln new file mode 100644 index 0000000..7c004d2 --- /dev/null +++ b/ComputerShopProvider/ComputerShopView/ComputerShopView.sln @@ -0,0 +1,49 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32819.101 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopView", "ComputerShopView.csproj", "{A1CA9942-BF79-4E2D-A6DE-318A308B7101}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopDataModels", "..\ComputerShopDataModels\ComputerShopDataModels.csproj", "{737F54AA-A6AF-4B6B-B692-44098F3F73C3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopBusinessLogic", "..\ComputerShopBusinessLogic\ComputerShopBusinessLogic.csproj", "{9D02C28B-9F01-4DD4-B53A-89EE456B4B04}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopContracts", "..\ComputerShopContracts\ComputerShopContracts.csproj", "{5D5A014D-835C-4D5A-A235-D2734F18D692}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopDatabaseImplement", "..\ComputerShopDatabaseImplement\ComputerShopDatabaseImplement.csproj", "{4A783C3D-2198-4F2C-9EC1-8C1E28201AC5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A1CA9942-BF79-4E2D-A6DE-318A308B7101}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A1CA9942-BF79-4E2D-A6DE-318A308B7101}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A1CA9942-BF79-4E2D-A6DE-318A308B7101}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A1CA9942-BF79-4E2D-A6DE-318A308B7101}.Release|Any CPU.Build.0 = Release|Any CPU + {737F54AA-A6AF-4B6B-B692-44098F3F73C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {737F54AA-A6AF-4B6B-B692-44098F3F73C3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {737F54AA-A6AF-4B6B-B692-44098F3F73C3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {737F54AA-A6AF-4B6B-B692-44098F3F73C3}.Release|Any CPU.Build.0 = Release|Any CPU + {9D02C28B-9F01-4DD4-B53A-89EE456B4B04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9D02C28B-9F01-4DD4-B53A-89EE456B4B04}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9D02C28B-9F01-4DD4-B53A-89EE456B4B04}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9D02C28B-9F01-4DD4-B53A-89EE456B4B04}.Release|Any CPU.Build.0 = Release|Any CPU + {5D5A014D-835C-4D5A-A235-D2734F18D692}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D5A014D-835C-4D5A-A235-D2734F18D692}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D5A014D-835C-4D5A-A235-D2734F18D692}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D5A014D-835C-4D5A-A235-D2734F18D692}.Release|Any CPU.Build.0 = Release|Any CPU + {4A783C3D-2198-4F2C-9EC1-8C1E28201AC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4A783C3D-2198-4F2C-9EC1-8C1E28201AC5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4A783C3D-2198-4F2C-9EC1-8C1E28201AC5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4A783C3D-2198-4F2C-9EC1-8C1E28201AC5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {302D7D50-419D-4A51-86D2-156F1DD93631} + EndGlobalSection +EndGlobal diff --git a/ComputerShopProvider/ComputerShopView/Form1.Designer.cs b/ComputerShopProvider/ComputerShopView/Form1.Designer.cs new file mode 100644 index 0000000..d7b60a8 --- /dev/null +++ b/ComputerShopProvider/ComputerShopView/Form1.Designer.cs @@ -0,0 +1,39 @@ +namespace ComputerShopView +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "Form1"; + } + + #endregion + } +} \ No newline at end of file diff --git a/ComputerShopProvider/ComputerShopView/Form1.cs b/ComputerShopProvider/ComputerShopView/Form1.cs new file mode 100644 index 0000000..9d879c0 --- /dev/null +++ b/ComputerShopProvider/ComputerShopView/Form1.cs @@ -0,0 +1,10 @@ +namespace ComputerShopView +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/ComputerShopProvider/ComputerShopView/Form1.resx b/ComputerShopProvider/ComputerShopView/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ComputerShopProvider/ComputerShopView/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ComputerShopProvider/ComputerShopView/Program.cs b/ComputerShopProvider/ComputerShopView/Program.cs new file mode 100644 index 0000000..ce62421 --- /dev/null +++ b/ComputerShopProvider/ComputerShopView/Program.cs @@ -0,0 +1,17 @@ +namespace ComputerShopView +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new Form1()); + } + } +} \ No newline at end of file