diff --git a/Secure/BusinessLogic/BusinessLogic.csproj b/Secure/BusinessLogic/BusinessLogic.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/Secure/BusinessLogic/BusinessLogic.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/Secure/BusinessLogic/Class1.cs b/Secure/BusinessLogic/Class1.cs new file mode 100644 index 0000000..67ecd1e --- /dev/null +++ b/Secure/BusinessLogic/Class1.cs @@ -0,0 +1,7 @@ +namespace BusinessLogic +{ + public class Class1 + { + + } +} \ No newline at end of file diff --git a/Secure/Secure.sln b/Secure/Secure.sln new file mode 100644 index 0000000..f7926bb --- /dev/null +++ b/Secure/Secure.sln @@ -0,0 +1,49 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32929.385 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Secure", "Secure\Secure.csproj", "{12E086AF-F155-48EC-B9B9-ABEF1B76B8DC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecureShopContracts", "SecureShopContracts\SecureShopContracts\SecureShopContracts.csproj", "{5F8E31D5-D9BD-4D40-BE28-12D12A91E4C7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecureShopDataModels", "SecureShopDataModels\SecureShopDataModels\SecureShopDataModels.csproj", "{3278670B-B887-4C00-B8A4-BAEED8C4F020}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecureShopBusinessLogic", "SecureShopBusinessLogic\SecureShopBusinessLogic.csproj", "{BA3B23C1-47F8-4734-BFE2-3F5A35C3BF2A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecureShopListImplement", "SecureShopListImplement\SecureShopListImplement.csproj", "{52CEC57F-E90F-4406-BB70-2B43B97D2358}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {12E086AF-F155-48EC-B9B9-ABEF1B76B8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {12E086AF-F155-48EC-B9B9-ABEF1B76B8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {12E086AF-F155-48EC-B9B9-ABEF1B76B8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {12E086AF-F155-48EC-B9B9-ABEF1B76B8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {5F8E31D5-D9BD-4D40-BE28-12D12A91E4C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5F8E31D5-D9BD-4D40-BE28-12D12A91E4C7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5F8E31D5-D9BD-4D40-BE28-12D12A91E4C7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5F8E31D5-D9BD-4D40-BE28-12D12A91E4C7}.Release|Any CPU.Build.0 = Release|Any CPU + {3278670B-B887-4C00-B8A4-BAEED8C4F020}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3278670B-B887-4C00-B8A4-BAEED8C4F020}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3278670B-B887-4C00-B8A4-BAEED8C4F020}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3278670B-B887-4C00-B8A4-BAEED8C4F020}.Release|Any CPU.Build.0 = Release|Any CPU + {BA3B23C1-47F8-4734-BFE2-3F5A35C3BF2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BA3B23C1-47F8-4734-BFE2-3F5A35C3BF2A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BA3B23C1-47F8-4734-BFE2-3F5A35C3BF2A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BA3B23C1-47F8-4734-BFE2-3F5A35C3BF2A}.Release|Any CPU.Build.0 = Release|Any CPU + {52CEC57F-E90F-4406-BB70-2B43B97D2358}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {52CEC57F-E90F-4406-BB70-2B43B97D2358}.Debug|Any CPU.Build.0 = Debug|Any CPU + {52CEC57F-E90F-4406-BB70-2B43B97D2358}.Release|Any CPU.ActiveCfg = Release|Any CPU + {52CEC57F-E90F-4406-BB70-2B43B97D2358}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {91A88ACE-177C-4A5D-BA80-5580140BF7E9} + EndGlobalSection +EndGlobal diff --git a/Secure/Secure/Form1.Designer.cs b/Secure/Secure/Form1.Designer.cs new file mode 100644 index 0000000..d6a6517 --- /dev/null +++ b/Secure/Secure/Form1.Designer.cs @@ -0,0 +1,39 @@ +namespace Secure +{ + 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/Secure/Secure/Form1.cs b/Secure/Secure/Form1.cs new file mode 100644 index 0000000..24aac69 --- /dev/null +++ b/Secure/Secure/Form1.cs @@ -0,0 +1,10 @@ +namespace Secure +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Secure/Secure/Form1.resx b/Secure/Secure/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Secure/Secure/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/Secure/Secure/Program.cs b/Secure/Secure/Program.cs new file mode 100644 index 0000000..e5c5365 --- /dev/null +++ b/Secure/Secure/Program.cs @@ -0,0 +1,17 @@ +namespace Secure +{ + 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 diff --git a/Secure/Secure/Secure.csproj b/Secure/Secure/Secure.csproj new file mode 100644 index 0000000..b57c89e --- /dev/null +++ b/Secure/Secure/Secure.csproj @@ -0,0 +1,11 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + \ No newline at end of file diff --git a/Secure/SecureShopBusinessLogic/BusinessLogic/ComponentLogic.cs b/Secure/SecureShopBusinessLogic/BusinessLogic/ComponentLogic.cs new file mode 100644 index 0000000..c9bcdd9 --- /dev/null +++ b/Secure/SecureShopBusinessLogic/BusinessLogic/ComponentLogic.cs @@ -0,0 +1,111 @@ +using Microsoft.Extensions.Logging; +using SecureShopContracts.BindingModels; +using SecureShopContracts.BusinessLogicsContracts; +using SecureShopContracts.SearchModels; +using SecureShopContracts.StorageContracts; +using SecureShopContracts.ViewModels; + +namespace SecureShopBusinessLogic.BusinessLogic +{ + 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("Компонент с таким названием уже есть"); + } + } + } +} \ No newline at end of file diff --git a/Secure/SecureShopBusinessLogic/SecureShopBusinessLogic.csproj b/Secure/SecureShopBusinessLogic/SecureShopBusinessLogic.csproj new file mode 100644 index 0000000..eba4ce4 --- /dev/null +++ b/Secure/SecureShopBusinessLogic/SecureShopBusinessLogic.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/Secure/SecureShopContracts/SecureShopContracts.sln b/Secure/SecureShopContracts/SecureShopContracts.sln new file mode 100644 index 0000000..ba2ec48 --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32929.385 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecureShopContracts", "SecureShopContracts\SecureShopContracts.csproj", "{06AD38FD-7CA7-45BA-A1C7-D8531F794FF5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {06AD38FD-7CA7-45BA-A1C7-D8531F794FF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {06AD38FD-7CA7-45BA-A1C7-D8531F794FF5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {06AD38FD-7CA7-45BA-A1C7-D8531F794FF5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {06AD38FD-7CA7-45BA-A1C7-D8531F794FF5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E76FFD02-B2F5-428E-950B-132138F2E535} + EndGlobalSection +EndGlobal diff --git a/Secure/SecureShopContracts/SecureShopContracts/BindingModels/ComponentBindingModel.cs b/Secure/SecureShopContracts/SecureShopContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..fc54a4b --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,11 @@ +using SecureShopDataModels.Models; +namespace SecureShopContracts.BindingModels +{ + public class ComponentBindingModel : IComponentModel + { + public int Id { get; set; } + public string ComponentName { get; set; } = string.Empty; + public double Cost { get; set; } + } + +} \ No newline at end of file diff --git a/Secure/SecureShopContracts/SecureShopContracts/BindingModels/OrderBindingModel.cs b/Secure/SecureShopContracts/SecureShopContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..14ff0d9 --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,22 @@ +using SecureShopDataModels.Enum; +using SecureShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + public int SecureId { get; set; } + public int Count { get; set; } + public double Sum { get; set; } + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + public DateTime DateCreate { get; set; } = DateTime.Now; + public DateTime? DateImplement { get; set; } + } + +} diff --git a/Secure/SecureShopContracts/SecureShopContracts/BindingModels/SecureBindingModel.cs b/Secure/SecureShopContracts/SecureShopContracts/BindingModels/SecureBindingModel.cs new file mode 100644 index 0000000..a554530 --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/BindingModels/SecureBindingModel.cs @@ -0,0 +1,21 @@ +using SecureShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopContracts.BindingModels +{ + public class SecureBindingModel : ISecureModel + { + public int Id { get; set; } + public string SecureName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary SecureComponents + { + get; + set; + } = new(); + } +} diff --git a/Secure/SecureShopContracts/SecureShopContracts/BusinessLogicsContracts/IComponentLogic.cs b/Secure/SecureShopContracts/SecureShopContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..d515a48 --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,21 @@ +using SecureShopContracts.BindingModels; +using SecureShopContracts.SearchModels; +using SecureShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopContracts.BusinessLogicsContracts +{ + 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/Secure/SecureShopContracts/SecureShopContracts/BusinessLogicsContracts/IOrderLogic.cs b/Secure/SecureShopContracts/SecureShopContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..0a12197 --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,20 @@ +using SecureShopContracts.BindingModels; +using SecureShopContracts.SearchModels; +using SecureShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopContracts.BusinessLogicsContracts +{ + public interface IOrderLogic + { + List? ReadList(OrderSearchModel? model); + bool CreateOrder(OrderBindingModel model); + bool TakeOrderInWork(OrderBindingModel model); + bool FinishOrder(OrderBindingModel model); + bool DeliveryOrder(OrderBindingModel model); + } +} diff --git a/Secure/SecureShopContracts/SecureShopContracts/BusinessLogicsContracts/ISecureLogic.cs b/Secure/SecureShopContracts/SecureShopContracts/BusinessLogicsContracts/ISecureLogic.cs new file mode 100644 index 0000000..dfe728a --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/BusinessLogicsContracts/ISecureLogic.cs @@ -0,0 +1,21 @@ +using SecureShopContracts.SearchModels; +using SecureShopContracts.BindingModels; +using SecureShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopContracts.BusinessLogicsContracts +{ + public interface ISecureLogic + { + List? ReadList(SecureSearchModel? model); + SecureViewModel? ReadElement(SecureSearchModel model); + bool Create(SecureBindingModel model); + bool Update(SecureBindingModel model); + bool Delete(SecureBindingModel model); + } + +} diff --git a/Secure/SecureShopContracts/SecureShopContracts/SearchModels/ComponentSearchModel.cs b/Secure/SecureShopContracts/SecureShopContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..ed86a99 --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } +} diff --git a/Secure/SecureShopContracts/SecureShopContracts/SearchModels/OrderSearchModel.cs b/Secure/SecureShopContracts/SecureShopContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..3d09960 --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/Secure/SecureShopContracts/SecureShopContracts/SearchModels/SecureSearchModel.cs b/Secure/SecureShopContracts/SecureShopContracts/SearchModels/SecureSearchModel.cs new file mode 100644 index 0000000..ce5f397 --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/SearchModels/SecureSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopContracts.SearchModels +{ + public class SecureSearchModel + { + public int? Id { get; set; } + public string? SecureName { get; set; } + } +} diff --git a/Secure/SecureShopContracts/SecureShopContracts/SecureShopContracts.csproj b/Secure/SecureShopContracts/SecureShopContracts/SecureShopContracts.csproj new file mode 100644 index 0000000..ca641e5 --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/SecureShopContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/Secure/SecureShopContracts/SecureShopContracts/StorageContracts/IComponentStorage.cs b/Secure/SecureShopContracts/SecureShopContracts/StorageContracts/IComponentStorage.cs new file mode 100644 index 0000000..7675e59 --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/StorageContracts/IComponentStorage.cs @@ -0,0 +1,22 @@ +using SecureShopContracts.BindingModels; +using SecureShopContracts.SearchModels; +using SecureShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopContracts.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/Secure/SecureShopContracts/SecureShopContracts/StorageContracts/IOrderStorage.cs b/Secure/SecureShopContracts/SecureShopContracts/StorageContracts/IOrderStorage.cs new file mode 100644 index 0000000..115d0cf --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/StorageContracts/IOrderStorage.cs @@ -0,0 +1,22 @@ +using SecureShopContracts.BindingModels; +using SecureShopContracts.SearchModels; +using SecureShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopContracts.StorageContracts +{ + public interface IOrderStorage + { + List GetFullList(); + List GetFilteredList(OrderSearchModel model); + OrderViewModel? GetElement(OrderSearchModel model); + OrderViewModel? Insert(OrderBindingModel model); + OrderViewModel? Update(OrderBindingModel model); + OrderViewModel? Delete(OrderBindingModel model); + } + +} diff --git a/Secure/SecureShopContracts/SecureShopContracts/StorageContracts/ISecureStorage.cs b/Secure/SecureShopContracts/SecureShopContracts/StorageContracts/ISecureStorage.cs new file mode 100644 index 0000000..e5b1667 --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/StorageContracts/ISecureStorage.cs @@ -0,0 +1,21 @@ +using SecureShopContracts.BindingModels; +using SecureShopContracts.SearchModels; +using SecureShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopContracts.StorageContracts +{ + public interface ISecureStorage + { + List GetFullList(); + List GetFilteredList(SecureSearchModel model); + SecureViewModel? GetElement(SecureSearchModel model); + SecureViewModel? Insert(SecureBindingModel model); + SecureViewModel? Update(SecureBindingModel model); + SecureViewModel? Delete(SecureBindingModel model); + } +} diff --git a/Secure/SecureShopContracts/SecureShopContracts/ViewModels/ComponentViewModel.cs b/Secure/SecureShopContracts/SecureShopContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..0c1ecc5 --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,19 @@ +using SecureShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopContracts.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/Secure/SecureShopContracts/SecureShopContracts/ViewModels/OrderViewModel.cs b/Secure/SecureShopContracts/SecureShopContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..78debd1 --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,31 @@ +using SecureShopDataModels.Enum; +using SecureShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + public int SecureId { get; set; } + [DisplayName("Изделие")] + public string SecureName { get; set; } = string.Empty; + [DisplayName("Количество")] + public int Count { get; set; } + [DisplayName("Сумма")] + public double Sum { get; set; } + [DisplayName("Статус")] + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + [DisplayName("Дата создания")] + public DateTime DateCreate { get; set; } = DateTime.Now; + [DisplayName("Дата выполнения")] + public DateTime? DateImplement { get; set; } + } + +} diff --git a/Secure/SecureShopContracts/SecureShopContracts/ViewModels/SecureViewModel.cs b/Secure/SecureShopContracts/SecureShopContracts/ViewModels/SecureViewModel.cs new file mode 100644 index 0000000..3bdd90f --- /dev/null +++ b/Secure/SecureShopContracts/SecureShopContracts/ViewModels/SecureViewModel.cs @@ -0,0 +1,25 @@ +using SecureShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopContracts.ViewModels +{ + public class SecureViewModel : ISecureModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string SecureName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary SecureComponents + { + get; + set; + } = new(); + } + +} diff --git a/Secure/SecureShopDataModels/SecureShopDataModels.sln b/Secure/SecureShopDataModels/SecureShopDataModels.sln new file mode 100644 index 0000000..e807d33 --- /dev/null +++ b/Secure/SecureShopDataModels/SecureShopDataModels.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32929.385 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecureShopDataModels", "SecureShopDataModels\SecureShopDataModels.csproj", "{11A90603-8AA1-4B6F-A4EE-8B70AB4A918F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {11A90603-8AA1-4B6F-A4EE-8B70AB4A918F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {11A90603-8AA1-4B6F-A4EE-8B70AB4A918F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {11A90603-8AA1-4B6F-A4EE-8B70AB4A918F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {11A90603-8AA1-4B6F-A4EE-8B70AB4A918F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E488F989-C9BB-4B7D-A085-2CA125E0D019} + EndGlobalSection +EndGlobal diff --git a/Secure/SecureShopDataModels/SecureShopDataModels/Enum/OrderStatus.cs b/Secure/SecureShopDataModels/SecureShopDataModels/Enum/OrderStatus.cs new file mode 100644 index 0000000..a84c87d --- /dev/null +++ b/Secure/SecureShopDataModels/SecureShopDataModels/Enum/OrderStatus.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopDataModels.Enum +{ + public enum OrderStatus + { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 + + } +} diff --git a/Secure/SecureShopDataModels/SecureShopDataModels/IId.cs b/Secure/SecureShopDataModels/SecureShopDataModels/IId.cs new file mode 100644 index 0000000..146ace0 --- /dev/null +++ b/Secure/SecureShopDataModels/SecureShopDataModels/IId.cs @@ -0,0 +1,7 @@ +namespace SecureShopDataModels +{ + public interface IId + { + int Id { get; } + } +} \ No newline at end of file diff --git a/Secure/SecureShopDataModels/SecureShopDataModels/Models/IComponentModel.cs b/Secure/SecureShopDataModels/SecureShopDataModels/Models/IComponentModel.cs new file mode 100644 index 0000000..0dd5ac2 --- /dev/null +++ b/Secure/SecureShopDataModels/SecureShopDataModels/Models/IComponentModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopDataModels.Models +{ + public interface IComponentModel:IId + { + string ComponentName { get;} + double Cost { get;} + } +} diff --git a/Secure/SecureShopDataModels/SecureShopDataModels/Models/IOrderModel.cs b/Secure/SecureShopDataModels/SecureShopDataModels/Models/IOrderModel.cs new file mode 100644 index 0000000..16aa42c --- /dev/null +++ b/Secure/SecureShopDataModels/SecureShopDataModels/Models/IOrderModel.cs @@ -0,0 +1,19 @@ +using SecureShopDataModels.Enum; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopDataModels.Models +{ + public interface IOrderModel:IId + { + int SecureId { get; } + int Count { get; } + double Sum { get; } + OrderStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get; } + } +} diff --git a/Secure/SecureShopDataModels/SecureShopDataModels/Models/ISecureModel.cs b/Secure/SecureShopDataModels/SecureShopDataModels/Models/ISecureModel.cs new file mode 100644 index 0000000..1594273 --- /dev/null +++ b/Secure/SecureShopDataModels/SecureShopDataModels/Models/ISecureModel.cs @@ -0,0 +1,16 @@ +using SecureShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopDataModels.Models +{ + public interface ISecureModel:IId + { + string SecureName { get; } + double Price { get; } + Dictionary SecureComponents { get; } + } +} diff --git a/Secure/SecureShopDataModels/SecureShopDataModels/SecureShopDataModels.csproj b/Secure/SecureShopDataModels/SecureShopDataModels/SecureShopDataModels.csproj new file mode 100644 index 0000000..27ac386 --- /dev/null +++ b/Secure/SecureShopDataModels/SecureShopDataModels/SecureShopDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/Secure/SecureShopListImplement/DataListSingleton.cs b/Secure/SecureShopListImplement/DataListSingleton.cs new file mode 100644 index 0000000..450208b --- /dev/null +++ b/Secure/SecureShopListImplement/DataListSingleton.cs @@ -0,0 +1,31 @@ +using SecureShopListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopListImplement +{ + public class DataListSingleton + { + private static DataListSingleton? _instance; + public List Components { get; set; } + public List Orders { get; set; } + public List Products { get; set; } + private DataListSingleton() + { + Components = new List(); + Orders = new List(); + Products = new List(); + } + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + return _instance; + } + } +} diff --git a/Secure/SecureShopListImplement/Models/Component.cs b/Secure/SecureShopListImplement/Models/Component.cs new file mode 100644 index 0000000..ababe0d --- /dev/null +++ b/Secure/SecureShopListImplement/Models/Component.cs @@ -0,0 +1,42 @@ +using SecureShopContracts.BindingModels; +using SecureShopContracts.ViewModels; +using SecureShopDataModels.Models; + +namespace SecureShopListImplement.Models +{ + public class Component : IComponentModel + { + public int Id { get; private set; } + public string ComponentName { get; private set; } = string.Empty; + public double Cost { get; set; } + public static Component? Create(ComponentBindingModel? model) + { + if (model == null) + { + return null; + } + return new Component() + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public void Update(ComponentBindingModel? model) + { + if (model == null) + { + return; + } + ComponentName = model.ComponentName; + Cost = model.Cost; + } + public ComponentViewModel GetViewModel => new() + { + Id = Id, + ComponentName = ComponentName, + Cost = Cost + }; + } + +} \ No newline at end of file diff --git a/Secure/SecureShopListImplement/Models/Order.cs b/Secure/SecureShopListImplement/Models/Order.cs new file mode 100644 index 0000000..9920f61 --- /dev/null +++ b/Secure/SecureShopListImplement/Models/Order.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopListImplement.Models +{ + public class Order + { + } +} diff --git a/Secure/SecureShopListImplement/Models/Secure.cs b/Secure/SecureShopListImplement/Models/Secure.cs new file mode 100644 index 0000000..cf605bb --- /dev/null +++ b/Secure/SecureShopListImplement/Models/Secure.cs @@ -0,0 +1,54 @@ +using SecureShopContracts.BindingModels; +using SecureShopContracts.ViewModels; +using SecureShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecureShopListImplement.Models +{ + public class Secure : ISecureModel + { + public int Id { get; private set; } + public string SecureName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary SecureComponents + { + get; + private set; + } = new Dictionary(); + public static Secure? Create(SecureBindingModel? model) + { + if (model == null) + { + return null; + } + return new Secure() + { + Id = model.Id, + SecureName = model.SecureName, + Price = model.Price, + SecureComponents = model.SecureComponents + }; + } + public void Update(SecureBindingModel? model) + { + if (model == null) + { + return; + } + SecureName = model.SecureName; + Price = model.Price; + SecureComponents = model.SecureComponents; + } + public SecureViewModel GetViewModel => new() + { + Id = Id, + SecureName = SecureName, + Price = Price, + SecureComponents = SecureComponents + }; + } +} diff --git a/Secure/SecureShopListImplement/SecureShopListImplement.csproj b/Secure/SecureShopListImplement/SecureShopListImplement.csproj new file mode 100644 index 0000000..c2fb905 --- /dev/null +++ b/Secure/SecureShopListImplement/SecureShopListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + +