diff --git a/AbstractSoftwareInstallationBusinessLogic/AbstractSoftwareInstallationBusinessLogic.csproj b/AbstractSoftwareInstallationBusinessLogic/AbstractSoftwareInstallationBusinessLogic.csproj
new file mode 100644
index 0000000..cfc61dd
--- /dev/null
+++ b/AbstractSoftwareInstallationBusinessLogic/AbstractSoftwareInstallationBusinessLogic.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/OrderLogic.cs b/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/OrderLogic.cs
new file mode 100644
index 0000000..107bd27
--- /dev/null
+++ b/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/OrderLogic.cs
@@ -0,0 +1,118 @@
+using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.SearchModels;
+using AbstractSoftwareInstallationContracts.ViewModels;
+using AbstractSoftwareInstallationContracts.StoragesContracts;
+using Microsoft.Extensions.Logging;
+using AbstractSoftwareInstallationDataModels;
+
+namespace AbstractSoftwareInstallationBusinessLogic.BusinessLogic
+{
+ public class OrderLogic : IOrderLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderStorage _orderStorage;
+ public OrderLogic(ILogger logger, IOrderStorage OrderStorage)
+ {
+ _logger = logger;
+ _orderStorage = OrderStorage;
+ }
+ private void CheckModel(OrderBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (model.PackageId < 0)
+ {
+ throw new ArgumentNullException("Некорректный идентификатор у суши", nameof(model.PackageId));
+ }
+ 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}. SushiId: { SushiId}", model.Id, model.Sum, model.PackageId);
+ }
+
+ public List? ReadList(OrderSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. Orderid:{ Id}", model?.Id);
+ var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+
+ public bool CreateOrder(OrderBindingModel model)
+ {
+ CheckModel(model);
+ if (model.Status != OrderStatus.Неизвестен)
+ {
+ _logger.LogWarning("Order status is incorrect");
+ return false;
+ }
+ model.Status = OrderStatus.Принят;
+ model.DateCreate = DateTime.Now;
+ if (_orderStorage.Insert(model) == null)
+ {
+ model.Status = OrderStatus.Неизвестен;
+ _logger.LogWarning("Failed to insert order into a storage");
+ return false;
+ }
+ return true;
+ }
+ public bool StatusUpdate(OrderBindingModel model, OrderStatus _newStatus)
+ {
+ var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
+ if (viewModel == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (viewModel.Status + 1 != _newStatus)
+ {
+ _logger.LogWarning("Status update to " + _newStatus.ToString() + " operation failed. Order status incorrect.");
+ return false;
+ }
+ model.Status = _newStatus;
+ if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.Now;
+ else
+ {
+ model.DateImplement = viewModel.DateImplement;
+ }
+ CheckModel(model, false);
+ if (_orderStorage.Update(model) == null)
+ {
+ model.Status--;
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool TakeOrderInWork(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Выполняется);
+ }
+
+ public bool DeliveryOrder(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Выдан);
+ }
+
+ public bool FinishOrder(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Готов);
+ }
+ }
+}
diff --git a/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/PackageLogic.cs b/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/PackageLogic.cs
new file mode 100644
index 0000000..6496126
--- /dev/null
+++ b/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/PackageLogic.cs
@@ -0,0 +1,110 @@
+using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.SearchModels;
+using AbstractSoftwareInstallationContracts.ViewModels;
+using AbstractSoftwareInstallationContracts.StoragesContracts;
+using Microsoft.Extensions.Logging;
+
+namespace AbstractSoftwareInstallationBusinessLogic.BusinessLogic
+{
+ public class PackageLogic : IPackageLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IPackageStorage _packageStorage;
+ public PackageLogic(ILogger logger, IPackageStorage PackageStorage)
+ {
+ _logger = logger;
+ _packageStorage = PackageStorage;
+ }
+ public List? ReadList(PackageSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. PackageName:{PackageName}.Id:{ Id}", model?.PackageName, model?.Id);
+ var list = model == null ? _packageStorage.GetFullList() : _packageStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public PackageViewModel? ReadElement(PackageSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. PackageName:{PackageName}.Id:{ Id}", model.PackageName, model.Id);
+ var element = _packageStorage.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(PackageBindingModel model)
+ {
+ CheckModel(model);
+ if (_packageStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+
+ }
+ public bool Update(PackageBindingModel model)
+ {
+ CheckModel(model);
+ if (_packageStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(PackageBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_packageStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(PackageBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.PackageName))
+ {
+ throw new ArgumentNullException("Нет названия пакета",
+ nameof(model.PackageName));
+ }
+ if (model.Price <= 0)
+ {
+ throw new ArgumentNullException("Цена пакета должна быть больше 0", nameof(model.Price));
+ }
+ _logger.LogInformation("Package. PackageName:{PackageName}.Price:{Price}. Id: {Id}", model.PackageName, model.Price, model.Id);
+ var element = _packageStorage.GetElement(new PackageSearchModel
+ {
+ PackageName = model.PackageName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Пакет с таким названием уже есть");
+ }
+ }
+ }
+
+}
diff --git a/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/SoftwareLogic.cs b/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/SoftwareLogic.cs
new file mode 100644
index 0000000..d941fd4
--- /dev/null
+++ b/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/SoftwareLogic.cs
@@ -0,0 +1,108 @@
+using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.SearchModels;
+using AbstractSoftwareInstallationContracts.ViewModels;
+using AbstractSoftwareInstallationContracts.StoragesContracts;
+using Microsoft.Extensions.Logging;
+
+
+namespace AbstractSoftwareInstallationBusinessLogic
+{
+ public class SoftwareLogic : ISoftwareLogic
+ {
+ private readonly ILogger _logger;
+ private readonly ISoftwareStorage _softwareStorage;
+ public SoftwareLogic(ILogger logger, ISoftwareStorage SoftwareStorage)
+ {
+ _logger = logger;
+ _softwareStorage = SoftwareStorage;
+ }
+ public List? ReadList(SoftwareSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. SoftwareName:{SoftwareName}.Id:{ Id}", model?.SoftwareName, model?.Id);
+ var list = model == null ? _softwareStorage.GetFullList() : _softwareStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public SoftwareViewModel? ReadElement(SoftwareSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. SoftwareName:{SoftwareName}.Id:{ Id}", model.SoftwareName, model.Id);
+ var element = _softwareStorage.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(SoftwareBindingModel model)
+ {
+ CheckModel(model);
+ if (_softwareStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+
+ }
+ public bool Update(SoftwareBindingModel model)
+ {
+ CheckModel(model);
+ if (_softwareStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(SoftwareBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_softwareStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(SoftwareBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.SoftwareName))
+ {
+ throw new ArgumentNullException("Нет названия ПО", nameof(model.SoftwareName));
+ }
+ if (model.Cost <= 0)
+ {
+ throw new ArgumentNullException("Цена ПО должна быть больше 0", nameof(model.Cost));
+ }
+ _logger.LogInformation("Software. SoftwareName:{SoftwareName}.Cost:{ Cost}. Id: { Id}", model.SoftwareName, model.Cost, model.Id);
+ var element = _softwareStorage.GetElement(new SoftwareSearchModel
+ {
+ SoftwareName = model.SoftwareName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("ПО с таким названием уже есть");
+ }
+ }
+ }}
\ No newline at end of file
diff --git a/AbstractSoftwareInstallationContracts/AbstractSoftwareInstallationContracts.csproj b/AbstractSoftwareInstallationContracts/AbstractSoftwareInstallationContracts.csproj
new file mode 100644
index 0000000..e427344
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/AbstractSoftwareInstallationContracts.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/AbstractSoftwareInstallationContracts/BindingModels/OrderBindingModel.cs b/AbstractSoftwareInstallationContracts/BindingModels/OrderBindingModel.cs
new file mode 100644
index 0000000..c00524b
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/BindingModels/OrderBindingModel.cs
@@ -0,0 +1,21 @@
+using AbstractSoftwareInstallationDataModels;
+using AbstractSoftwareInstallationDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractSoftwareInstallationContracts.BindingModels
+{
+ public class OrderBindingModel : IOrderModel
+ {
+ public int Id { get; set; }
+ public int PackageId { 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/AbstractSoftwareInstallationContracts/BindingModels/PackageBindingModel.cs b/AbstractSoftwareInstallationContracts/BindingModels/PackageBindingModel.cs
new file mode 100644
index 0000000..de834db
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/BindingModels/PackageBindingModel.cs
@@ -0,0 +1,18 @@
+using AbstractSoftwareInstallationDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractSoftwareInstallationContracts.BindingModels
+{
+ public class PackageBindingModel : IPackageModel
+ {
+ public int Id { get; set; }
+ public string PackageName { get; set; } = string.Empty;
+ public double Price { get; set; }
+ public Dictionary PackageSoftware{get;set;} = new();
+
+ }
+}
diff --git a/AbstractSoftwareInstallationContracts/BindingModels/SoftwareBindingModel.cs b/AbstractSoftwareInstallationContracts/BindingModels/SoftwareBindingModel.cs
new file mode 100644
index 0000000..8d92d22
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/BindingModels/SoftwareBindingModel.cs
@@ -0,0 +1,11 @@
+using AbstractSoftwareInstallationDataModels.Models;
+
+namespace AbstractSoftwareInstallationContracts.BindingModels
+{
+ public class SoftwareBindingModel : ISoftwareModel
+ {
+ public int Id { get; set; }
+ public string SoftwareName { get; set; } = string.Empty;
+ public double Cost { get; set; }
+ }
+}
diff --git a/AbstractSoftwareInstallationContracts/BusinessLogicsContracts/IOrderLogic.cs b/AbstractSoftwareInstallationContracts/BusinessLogicsContracts/IOrderLogic.cs
new file mode 100644
index 0000000..909382f
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/BusinessLogicsContracts/IOrderLogic.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.SearchModels;
+using AbstractSoftwareInstallationContracts.ViewModels;
+
+namespace AbstractSoftwareInstallationContracts.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/AbstractSoftwareInstallationContracts/BusinessLogicsContracts/IPackageLogic.cs b/AbstractSoftwareInstallationContracts/BusinessLogicsContracts/IPackageLogic.cs
new file mode 100644
index 0000000..6dd24a0
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/BusinessLogicsContracts/IPackageLogic.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.SearchModels;
+using AbstractSoftwareInstallationContracts.ViewModels;
+
+namespace AbstractSoftwareInstallationContracts.BusinessLogicsContracts
+{
+ public interface IPackageLogic
+ {
+ List? ReadList(PackageSearchModel? model);
+ PackageViewModel? ReadElement(PackageSearchModel model);
+ bool Create(PackageBindingModel model);
+ bool Update(PackageBindingModel model);
+ bool Delete(PackageBindingModel model);
+ }
+}
diff --git a/AbstractSoftwareInstallationContracts/BusinessLogicsContracts/ISoftwareLogic.cs b/AbstractSoftwareInstallationContracts/BusinessLogicsContracts/ISoftwareLogic.cs
new file mode 100644
index 0000000..9bac33a
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/BusinessLogicsContracts/ISoftwareLogic.cs
@@ -0,0 +1,20 @@
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.SearchModels;
+using AbstractSoftwareInstallationContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractSoftwareInstallationContracts.BusinessLogicsContracts
+{
+ public interface ISoftwareLogic
+ {
+ List? ReadList(SoftwareSearchModel? model);
+ SoftwareViewModel? ReadElement(SoftwareSearchModel model);
+ bool Create(SoftwareBindingModel model);
+ bool Update(SoftwareBindingModel model);
+ bool Delete(SoftwareBindingModel model);
+ }
+}
diff --git a/AbstractSoftwareInstallationContracts/SearchModels/OrderSearchModel.cs b/AbstractSoftwareInstallationContracts/SearchModels/OrderSearchModel.cs
new file mode 100644
index 0000000..463d477
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/SearchModels/OrderSearchModel.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractSoftwareInstallationContracts.SearchModels
+{
+ public class OrderSearchModel
+ {
+ public int? Id { get; set; }
+ }
+}
diff --git a/AbstractSoftwareInstallationContracts/SearchModels/PackageSearchModel.cs b/AbstractSoftwareInstallationContracts/SearchModels/PackageSearchModel.cs
new file mode 100644
index 0000000..ce80031
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/SearchModels/PackageSearchModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractSoftwareInstallationContracts.SearchModels
+{
+ public class PackageSearchModel
+ {
+ public int? Id { get; set; }
+ public string? PackageName { get; set; }
+ }
+}
diff --git a/AbstractSoftwareInstallationContracts/SearchModels/SoftwareSearchModel.cs b/AbstractSoftwareInstallationContracts/SearchModels/SoftwareSearchModel.cs
new file mode 100644
index 0000000..139f97c
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/SearchModels/SoftwareSearchModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractSoftwareInstallationContracts.SearchModels
+{
+ public class SoftwareSearchModel
+ {
+ public int? Id { get; set; }
+ public string? SoftwareName { get; set; }
+
+ }
+}
diff --git a/AbstractSoftwareInstallationContracts/StoragesContracts/IOrderStorage.cs b/AbstractSoftwareInstallationContracts/StoragesContracts/IOrderStorage.cs
new file mode 100644
index 0000000..5693839
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/StoragesContracts/IOrderStorage.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.SearchModels;
+using AbstractSoftwareInstallationContracts.ViewModels;
+
+namespace AbstractSoftwareInstallationContracts.StoragesContracts
+{
+ 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/AbstractSoftwareInstallationContracts/StoragesContracts/IPackageStorage.cs b/AbstractSoftwareInstallationContracts/StoragesContracts/IPackageStorage.cs
new file mode 100644
index 0000000..c0b679f
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/StoragesContracts/IPackageStorage.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.SearchModels;
+using AbstractSoftwareInstallationContracts.ViewModels;
+
+
+namespace AbstractSoftwareInstallationContracts.StoragesContracts
+{
+ public interface IPackageStorage
+ {
+ List GetFullList();
+ List GetFilteredList(PackageSearchModel model);
+ PackageViewModel? GetElement(PackageSearchModel model);
+ PackageViewModel? Insert(PackageBindingModel model);
+ PackageViewModel? Update(PackageBindingModel model);
+ PackageViewModel? Delete(PackageBindingModel model);
+ }
+}
diff --git a/AbstractSoftwareInstallationContracts/StoragesContracts/ISoftwareStorage.cs b/AbstractSoftwareInstallationContracts/StoragesContracts/ISoftwareStorage.cs
new file mode 100644
index 0000000..6e96641
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/StoragesContracts/ISoftwareStorage.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.SearchModels;
+using AbstractSoftwareInstallationContracts.ViewModels;
+
+namespace AbstractSoftwareInstallationContracts.StoragesContracts
+{
+ public interface ISoftwareStorage
+ {
+ List GetFullList();
+ List GetFilteredList(SoftwareSearchModel model);
+ SoftwareViewModel? GetElement(SoftwareSearchModel model);
+ SoftwareViewModel? Insert(SoftwareBindingModel model);
+ SoftwareViewModel? Update(SoftwareBindingModel model);
+ SoftwareViewModel? Delete(SoftwareBindingModel model);
+ }
+}
diff --git a/AbstractSoftwareInstallationContracts/ViewModels/OrderViewModel.cs b/AbstractSoftwareInstallationContracts/ViewModels/OrderViewModel.cs
new file mode 100644
index 0000000..4c32e6c
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/ViewModels/OrderViewModel.cs
@@ -0,0 +1,31 @@
+using System;
+using System.ComponentModel;
+using AbstractSoftwareInstallationDataModels;
+using AbstractSoftwareInstallationDataModels.Models;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractSoftwareInstallationContracts.ViewModels
+{
+ public class OrderViewModel : IOrderModel
+ {
+
+ [DisplayName("Номер заказа")]
+ public int Id { get; set; }
+ public int PackageId { get; set; }
+ [DisplayName("Пакет")]
+ public string PackageName { 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/AbstractSoftwareInstallationContracts/ViewModels/PackageViewModel.cs b/AbstractSoftwareInstallationContracts/ViewModels/PackageViewModel.cs
new file mode 100644
index 0000000..b58ea0c
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/ViewModels/PackageViewModel.cs
@@ -0,0 +1,25 @@
+using AbstractSoftwareInstallationDataModels.Models;
+using System.ComponentModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractSoftwareInstallationContracts.ViewModels
+{
+ public class PackageViewModel : IPackageModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Package Name")]
+ public string PackageName { get; set; } = string.Empty;
+ [DisplayName("Price")]
+ public double Price { get; set; }
+ public Dictionary PackageSoftware
+ {
+ get;
+ set;
+ } = new();
+
+ }
+}
diff --git a/AbstractSoftwareInstallationContracts/ViewModels/SoftwareViewModel.cs b/AbstractSoftwareInstallationContracts/ViewModels/SoftwareViewModel.cs
new file mode 100644
index 0000000..b8ed809
--- /dev/null
+++ b/AbstractSoftwareInstallationContracts/ViewModels/SoftwareViewModel.cs
@@ -0,0 +1,19 @@
+using AbstractSoftwareInstallationDataModels.Models;
+using System.ComponentModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractSoftwareInstallationContracts.ViewModels
+{
+ public class SoftwareViewModel : ISoftwareModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название")]
+ public string SoftwareName { get; set; } = string.Empty;
+ [DisplayName("Цена")]
+ public double Cost { get; set; }
+ }
+}
diff --git a/AbstractSoftwareInstallationDataModels/AbstractSoftwareInstallationDataModels.csproj b/AbstractSoftwareInstallationDataModels/AbstractSoftwareInstallationDataModels.csproj
new file mode 100644
index 0000000..27ac386
--- /dev/null
+++ b/AbstractSoftwareInstallationDataModels/AbstractSoftwareInstallationDataModels.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/AbstractSoftwareInstallationDataModels/IId.cs b/AbstractSoftwareInstallationDataModels/IId.cs
new file mode 100644
index 0000000..a8b739c
--- /dev/null
+++ b/AbstractSoftwareInstallationDataModels/IId.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractSoftwareInstallationDataModels
+{
+ public interface IId
+ {
+ int Id { get; }
+ }
+}
diff --git a/AbstractSoftwareInstallationDataModels/Models/IOrderModel.cs b/AbstractSoftwareInstallationDataModels/Models/IOrderModel.cs
new file mode 100644
index 0000000..5036ba4
--- /dev/null
+++ b/AbstractSoftwareInstallationDataModels/Models/IOrderModel.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractSoftwareInstallationDataModels.Models
+{
+ public interface IOrderModel : IId
+ {
+ int PackageId { get; }
+ int Count { get; }
+ double Sum { get; }
+ OrderStatus Status { get; }
+ DateTime DateCreate { get; }
+ DateTime? DateImplement { get; }
+
+ }
+}
diff --git a/AbstractSoftwareInstallationDataModels/Models/IPackageModel.cs b/AbstractSoftwareInstallationDataModels/Models/IPackageModel.cs
new file mode 100644
index 0000000..f8504f2
--- /dev/null
+++ b/AbstractSoftwareInstallationDataModels/Models/IPackageModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractSoftwareInstallationDataModels.Models
+{
+ public interface IPackageModel : IId
+ {
+ string PackageName { get; }
+ double Price { get; }
+ Dictionary PackageSoftware { get; }
+ }
+}
diff --git a/AbstractSoftwareInstallationDataModels/Models/ISoftwareModel.cs b/AbstractSoftwareInstallationDataModels/Models/ISoftwareModel.cs
new file mode 100644
index 0000000..6bed69a
--- /dev/null
+++ b/AbstractSoftwareInstallationDataModels/Models/ISoftwareModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractSoftwareInstallationDataModels.Models
+{
+ public interface ISoftwareModel : IId
+ {
+ string SoftwareName { get; }
+ double Cost { get; }
+ }
+}
diff --git a/AbstractSoftwareInstallationDataModels/OrderStatus.cs b/AbstractSoftwareInstallationDataModels/OrderStatus.cs
new file mode 100644
index 0000000..6d44cfb
--- /dev/null
+++ b/AbstractSoftwareInstallationDataModels/OrderStatus.cs
@@ -0,0 +1,11 @@
+namespace AbstractSoftwareInstallationDataModels
+{
+ public enum OrderStatus
+ {
+ Неизвестен = -1,
+ Принят = 0,
+ Выполняется = 1,
+ Готов = 2,
+ Выдан = 3
+ }
+}
\ No newline at end of file
diff --git a/AbstractSoftwareInstallationListImplement/AbstractSoftwareInstallationListImplement.csproj b/AbstractSoftwareInstallationListImplement/AbstractSoftwareInstallationListImplement.csproj
new file mode 100644
index 0000000..2b56355
--- /dev/null
+++ b/AbstractSoftwareInstallationListImplement/AbstractSoftwareInstallationListImplement.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/AbstractSoftwareInstallationListImplement/DataListSingleton.cs b/AbstractSoftwareInstallationListImplement/DataListSingleton.cs
new file mode 100644
index 0000000..92c5b06
--- /dev/null
+++ b/AbstractSoftwareInstallationListImplement/DataListSingleton.cs
@@ -0,0 +1,31 @@
+using AbstractSoftwareInstallationListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractSoftwareInstallationListImplement
+{
+ public class DataListSingleton
+ {
+ private static DataListSingleton? _instance;
+ public List Softwares { get; set; }
+ public List Orders { get; set; }
+ public List Packages { get; set; }
+ private DataListSingleton()
+ {
+ Softwares = new List();
+ Orders = new List();
+ Packages = new List();
+ }
+ public static DataListSingleton GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new DataListSingleton();
+ }
+ return _instance;
+ }
+ }
+}
diff --git a/AbstractSoftwareInstallationListImplement/Implements/OrderStorage.cs b/AbstractSoftwareInstallationListImplement/Implements/OrderStorage.cs
new file mode 100644
index 0000000..41be27c
--- /dev/null
+++ b/AbstractSoftwareInstallationListImplement/Implements/OrderStorage.cs
@@ -0,0 +1,122 @@
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.SearchModels;
+using AbstractSoftwareInstallationContracts.StoragesContracts;
+using AbstractSoftwareInstallationContracts.ViewModels;
+using AbstractSoftwareInstallationListImplement;
+using AbstractSoftwareInstallationListImplement.Models;
+
+namespace AbstractOrderInstallationListImplement.Implements
+{
+ public class OrderStorage : IOrderStorage
+ {
+ private readonly DataListSingleton _source;
+
+ public OrderStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+
+ public OrderViewModel? GetElement(OrderSearchModel model)
+ {
+ if (!model.Id.HasValue)
+ {
+ return null;
+ }
+
+ foreach (var order in _source.Orders)
+ {
+ if (model.Id.HasValue && order.Id == model.Id)
+ {
+ return GetViewModel(order);
+ }
+ }
+
+ return null;
+ }
+
+ public List GetFilteredList(OrderSearchModel model)
+ {
+ var result = new List();
+ if (!model.Id.HasValue)
+ {
+ return result;
+ }
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ result.Add(GetViewModel(order));
+ }
+ }
+ return result;
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var order in _source.Orders)
+ {
+ result.Add(GetViewModel(order));
+ }
+ return result;
+ }
+
+ public OrderViewModel? Insert(OrderBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var order in _source.Orders)
+ {
+ if (model.Id <= order.Id)
+ {
+ model.Id = order.Id + 1;
+ }
+ }
+ var newOrder = Order.Create(model);
+ if (newOrder == null)
+ {
+ return null;
+ }
+ _source.Orders.Add(newOrder);
+ return GetViewModel(newOrder);
+ }
+
+ public OrderViewModel? Update(OrderBindingModel model)
+ {
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ order.Update(model);
+ return GetViewModel(order);
+ }
+ }
+ return null;
+ }
+ public OrderViewModel? Delete(OrderBindingModel model)
+ {
+ for (int i = 0; i < _source.Orders.Count; ++i)
+ {
+ if (_source.Orders[i].Id == model.Id)
+ {
+ var element = _source.Orders[i];
+ _source.Orders.RemoveAt(i);
+ return GetViewModel(element);
+ }
+ }
+ return null;
+ }
+ private OrderViewModel GetViewModel(Order order)
+ {
+ var viewModel = order.GetViewModel;
+ foreach (var package in _source.Packages)
+ {
+ if (package.Id == order.PackageId)
+ {
+ viewModel.PackageName = package.PackageName;
+ break;
+ }
+ }
+ return viewModel;
+ }
+ }
+}
diff --git a/AbstractSoftwareInstallationListImplement/Implements/PackageStorage.cs b/AbstractSoftwareInstallationListImplement/Implements/PackageStorage.cs
new file mode 100644
index 0000000..22a3c42
--- /dev/null
+++ b/AbstractSoftwareInstallationListImplement/Implements/PackageStorage.cs
@@ -0,0 +1,109 @@
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.SearchModels;
+using AbstractSoftwareInstallationContracts.StoragesContracts;
+using AbstractSoftwareInstallationContracts.ViewModels;
+using AbstractSoftwareInstallationListImplement;
+using AbstractSoftwareInstallationListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractPackageInstallationListImplement.Implements
+{
+ public class PackageStorage : IPackageStorage
+ {
+ private readonly DataListSingleton _source;
+ public PackageStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var package in _source.Packages)
+ {
+ result.Add(package.GetViewModel);
+ }
+ return result;
+ }
+ public List GetFilteredList(PackageSearchModel
+ model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.PackageName))
+ {
+ return result;
+ }
+ foreach (var package in _source.Packages)
+ {
+ if (package.PackageName.Contains(model.PackageName))
+ {
+ result.Add(package.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public PackageViewModel? GetElement(PackageSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.PackageName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var package in _source.Packages)
+ {
+ if ((!string.IsNullOrEmpty(model.PackageName) &&
+ package.PackageName == model.PackageName) ||
+ (model.Id.HasValue && package.Id == model.Id))
+ {
+ return package.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public PackageViewModel? Insert(PackageBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var package in _source.Packages)
+ {
+ if (model.Id <= package.Id)
+ {
+ model.Id = package.Id + 1;
+ }
+ }
+ var newPackage = Package.Create(model);
+ if (newPackage == null)
+ {
+ return null;
+ }
+ _source.Packages.Add(newPackage);
+ return newPackage.GetViewModel;
+ }
+ public PackageViewModel? Update(PackageBindingModel model)
+ {
+ foreach (var package in _source.Packages)
+ {
+ if (package.Id == model.Id)
+ {
+ package.Update(model);
+ return package.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public PackageViewModel? Delete(PackageBindingModel model)
+ {
+ for (int i = 0; i < _source.Packages.Count; ++i)
+ {
+ if (_source.Packages[i].Id == model.Id)
+ {
+ var element = _source.Packages[i];
+ _source.Packages.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/AbstractSoftwareInstallationListImplement/Implements/SoftwareStorage.cs b/AbstractSoftwareInstallationListImplement/Implements/SoftwareStorage.cs
new file mode 100644
index 0000000..137f530
--- /dev/null
+++ b/AbstractSoftwareInstallationListImplement/Implements/SoftwareStorage.cs
@@ -0,0 +1,104 @@
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.SearchModels;
+using AbstractSoftwareInstallationContracts.StoragesContracts;
+using AbstractSoftwareInstallationContracts.ViewModels;
+using AbstractSoftwareInstallationListImplement.Models;
+
+namespace AbstractSoftwareInstallationListImplement.Implements
+{
+ public class SoftwareStorage : ISoftwareStorage
+ {
+ private readonly DataListSingleton _source;
+ public SoftwareStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var component in _source.Softwares)
+ {
+ result.Add(component.GetViewModel);
+ }
+ return result;
+ }
+ public List GetFilteredList(SoftwareSearchModel
+ model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.SoftwareName))
+ {
+ return result;
+ }
+ foreach (var component in _source.Softwares)
+ {
+ if (component.SoftwareName.Contains(model.SoftwareName))
+ {
+ result.Add(component.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public SoftwareViewModel? GetElement(SoftwareSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.SoftwareName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var software in _source.Softwares)
+ {
+ if ((!string.IsNullOrEmpty(model.SoftwareName) &&
+ software.SoftwareName == model.SoftwareName) ||
+ (model.Id.HasValue && software.Id == model.Id))
+ {
+ return software.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public SoftwareViewModel? Insert(SoftwareBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var software in _source.Softwares)
+ {
+ if (model.Id <= software.Id)
+ {
+ model.Id = software.Id + 1;
+ }
+ }
+ var newSoftware = Software.Create(model);
+ if (newSoftware == null)
+ {
+ return null;
+ }
+ _source.Softwares.Add(newSoftware);
+ return newSoftware.GetViewModel;
+ }
+ public SoftwareViewModel? Update(SoftwareBindingModel model)
+ {
+ foreach (var component in _source.Softwares)
+ {
+ if (component.Id == model.Id)
+ {
+ component.Update(model);
+ return component.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public SoftwareViewModel? Delete(SoftwareBindingModel model)
+ {
+ for (int i = 0; i < _source.Softwares.Count; ++i)
+ {
+ if (_source.Softwares[i].Id == model.Id)
+ {
+ var element = _source.Softwares[i];
+ _source.Softwares.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+
+ }
+}
diff --git a/AbstractSoftwareInstallationListImplement/Models/Order.cs b/AbstractSoftwareInstallationListImplement/Models/Order.cs
new file mode 100644
index 0000000..e564f94
--- /dev/null
+++ b/AbstractSoftwareInstallationListImplement/Models/Order.cs
@@ -0,0 +1,59 @@
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.ViewModels;
+using AbstractSoftwareInstallationDataModels;
+using AbstractSoftwareInstallationDataModels.Models;
+
+namespace AbstractSoftwareInstallationListImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int PackageId { get; private set; }
+
+ public int Count { get; private set; }
+
+ public double Sum { get; private set; }
+
+ public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
+
+ public DateTime DateCreate { get; private set; } = DateTime.Now;
+
+ public DateTime? DateImplement { get; private set; }
+
+ public int Id { get; private set; }
+
+ public static Order? Create(OrderBindingModel? model)
+ {
+ if (model == null) return null;
+ return new Order
+ {
+ PackageId = model.PackageId,
+ Count = model.Count,
+ Sum = model.Sum,
+ Status = model.Status,
+ DateCreate = model.DateCreate,
+ DateImplement = model.DateImplement,
+ Id = model.Id,
+ };
+ }
+
+ public void Update(OrderBindingModel model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ Status = model.Status;
+ DateImplement = model.DateImplement;
+ }
+ public OrderViewModel GetViewModel => new()
+ {
+ Id = Id,
+ PackageId = PackageId,
+ Count = Count,
+ Sum = Sum,
+ Status = Status,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement
+ };
+ }
+}
diff --git a/AbstractSoftwareInstallationListImplement/Models/Package.cs b/AbstractSoftwareInstallationListImplement/Models/Package.cs
new file mode 100644
index 0000000..91c3b4e
--- /dev/null
+++ b/AbstractSoftwareInstallationListImplement/Models/Package.cs
@@ -0,0 +1,50 @@
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.ViewModels;
+using AbstractSoftwareInstallationDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractSoftwareInstallationListImplement.Models
+{
+ public class Package : IPackageModel
+ {
+ public string PackageName { get; private set; } = string.Empty;
+
+ public double Price { get; set; }
+
+ public Dictionary PackageSoftware { get; private set; } = new Dictionary();
+
+ public int Id { get; private set; }
+ public static Package? Create(PackageBindingModel? model)
+ {
+ if (model == null) return null;
+ return new Package
+ {
+ Id = model.Id,
+ PackageName = model.PackageName,
+ Price = model.Price,
+ PackageSoftware = model.PackageSoftware
+ };
+ }
+ public void Update(PackageBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ PackageName = model.PackageName;
+ Price = model.Price;
+ PackageSoftware = model.PackageSoftware;
+ }
+ public PackageViewModel GetViewModel => new()
+ {
+ Id = Id,
+ PackageName = PackageName,
+ Price = Price,
+ PackageSoftware = PackageSoftware
+ };
+ }
+}
diff --git a/AbstractSoftwareInstallationListImplement/Models/Software.cs b/AbstractSoftwareInstallationListImplement/Models/Software.cs
new file mode 100644
index 0000000..2e44eca
--- /dev/null
+++ b/AbstractSoftwareInstallationListImplement/Models/Software.cs
@@ -0,0 +1,43 @@
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.ViewModels;
+using AbstractSoftwareInstallationDataModels.Models;
+
+namespace AbstractSoftwareInstallationListImplement.Models
+{
+ public class Software : ISoftwareModel
+ {
+ public string SoftwareName { get; private set; } = String.Empty;
+
+ public double Cost { get; set; }
+
+ public int Id { get; private set; }
+ public static Software? Create(SoftwareBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Software()
+ {
+ Id = model.Id,
+ SoftwareName = model.SoftwareName,
+ Cost = model.Cost
+ };
+ }
+ public void Update(SoftwareBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ SoftwareName = model.SoftwareName;
+ Cost = model.Cost;
+ }
+ public SoftwareViewModel GetViewModel => new()
+ {
+ Id = Id,
+ SoftwareName = SoftwareName,
+ Cost = Cost
+ };
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation.sln b/SoftwareInstallation.sln
new file mode 100644
index 0000000..7d3feaa
--- /dev/null
+++ b/SoftwareInstallation.sln
@@ -0,0 +1,49 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.0.31903.59
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SoftwareInstallationView", "SoftwareInstallation\SoftwareInstallationView.csproj", "{18A0C203-2758-444C-AF35-2635F88FDB35}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractSoftwareInstallationDataModels", "AbstractSoftwareInstallationDataModels\AbstractSoftwareInstallationDataModels.csproj", "{A883A624-D446-4834-9C5F-6364F0E66314}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractSoftwareInstallationContracts", "AbstractSoftwareInstallationContracts\AbstractSoftwareInstallationContracts.csproj", "{4DA94347-C949-462B-B361-18D297C65CC2}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractSoftwareInstallationBusinessLogic", "AbstractSoftwareInstallationBusinessLogic\AbstractSoftwareInstallationBusinessLogic.csproj", "{76E33F5D-6D55-4C28-B26B-9F33B10BA3EF}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractSoftwareInstallationListImplement", "AbstractSoftwareInstallationListImplement\AbstractSoftwareInstallationListImplement.csproj", "{31AD2872-9651-476A-9868-C4404FEEB0E4}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {18A0C203-2758-444C-AF35-2635F88FDB35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {18A0C203-2758-444C-AF35-2635F88FDB35}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {18A0C203-2758-444C-AF35-2635F88FDB35}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {18A0C203-2758-444C-AF35-2635F88FDB35}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A883A624-D446-4834-9C5F-6364F0E66314}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A883A624-D446-4834-9C5F-6364F0E66314}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A883A624-D446-4834-9C5F-6364F0E66314}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A883A624-D446-4834-9C5F-6364F0E66314}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4DA94347-C949-462B-B361-18D297C65CC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4DA94347-C949-462B-B361-18D297C65CC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4DA94347-C949-462B-B361-18D297C65CC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4DA94347-C949-462B-B361-18D297C65CC2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {76E33F5D-6D55-4C28-B26B-9F33B10BA3EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {76E33F5D-6D55-4C28-B26B-9F33B10BA3EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {76E33F5D-6D55-4C28-B26B-9F33B10BA3EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {76E33F5D-6D55-4C28-B26B-9F33B10BA3EF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {31AD2872-9651-476A-9868-C4404FEEB0E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {31AD2872-9651-476A-9868-C4404FEEB0E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {31AD2872-9651-476A-9868-C4404FEEB0E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {31AD2872-9651-476A-9868-C4404FEEB0E4}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {65E51AEC-89CD-4164-8821-934839107D27}
+ EndGlobalSection
+EndGlobal
diff --git a/SoftwareInstallation/Form1.Designer.cs b/SoftwareInstallation/Form1.Designer.cs
new file mode 100644
index 0000000..662fcdd
--- /dev/null
+++ b/SoftwareInstallation/Form1.Designer.cs
@@ -0,0 +1,39 @@
+namespace SoftwareInstallation
+{
+ 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/SoftwareInstallation/Form1.cs b/SoftwareInstallation/Form1.cs
new file mode 100644
index 0000000..b325dd6
--- /dev/null
+++ b/SoftwareInstallation/Form1.cs
@@ -0,0 +1,10 @@
+namespace SoftwareInstallation
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+ }
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/FormCreateOrder.Designer.cs b/SoftwareInstallation/FormCreateOrder.Designer.cs
new file mode 100644
index 0000000..585201a
--- /dev/null
+++ b/SoftwareInstallation/FormCreateOrder.Designer.cs
@@ -0,0 +1,145 @@
+namespace SoftwareInstallationView
+{
+ partial class FormCreateOrder
+ {
+ ///
+ /// 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.comboBoxPackage = new System.Windows.Forms.ComboBox();
+ this.textBoxCount = new System.Windows.Forms.TextBox();
+ this.textBoxSum = new System.Windows.Forms.TextBox();
+ this.labelPackage = new System.Windows.Forms.Label();
+ this.labelCount = new System.Windows.Forms.Label();
+ this.labelSum = new System.Windows.Forms.Label();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // comboBoxPackage
+ //
+ this.comboBoxPackage.BackColor = System.Drawing.SystemColors.Window;
+ this.comboBoxPackage.FormattingEnabled = true;
+ this.comboBoxPackage.Location = new System.Drawing.Point(110, 24);
+ this.comboBoxPackage.Name = "comboBoxPackage";
+ this.comboBoxPackage.Size = new System.Drawing.Size(310, 23);
+ this.comboBoxPackage.TabIndex = 0;
+ this.comboBoxPackage.SelectedIndexChanged += new System.EventHandler(this.ComboBoxProduct_SelectedIndexChanged);
+ //
+ // textBoxCount
+ //
+ this.textBoxCount.Location = new System.Drawing.Point(110, 62);
+ this.textBoxCount.Name = "textBoxCount";
+ this.textBoxCount.Size = new System.Drawing.Size(310, 23);
+ this.textBoxCount.TabIndex = 1;
+ this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
+ //
+ // textBoxSum
+ //
+ this.textBoxSum.Location = new System.Drawing.Point(110, 101);
+ this.textBoxSum.Name = "textBoxSum";
+ this.textBoxSum.Size = new System.Drawing.Size(310, 23);
+ this.textBoxSum.TabIndex = 2;
+ //
+ // labelPackage
+ //
+ this.labelPackage.AutoSize = true;
+ this.labelPackage.Location = new System.Drawing.Point(29, 27);
+ this.labelPackage.Name = "labelPackage";
+ this.labelPackage.Size = new System.Drawing.Size(42, 15);
+ this.labelPackage.TabIndex = 3;
+ this.labelPackage.Text = "Пакет:";
+ //
+ // labelCount
+ //
+ this.labelCount.AutoSize = true;
+ this.labelCount.Location = new System.Drawing.Point(29, 65);
+ this.labelCount.Name = "labelCount";
+ this.labelCount.Size = new System.Drawing.Size(75, 15);
+ this.labelCount.TabIndex = 4;
+ this.labelCount.Text = "Количество:";
+ //
+ // labelSum
+ //
+ this.labelSum.AutoSize = true;
+ this.labelSum.Location = new System.Drawing.Point(29, 104);
+ this.labelSum.Name = "labelSum";
+ this.labelSum.Size = new System.Drawing.Size(48, 15);
+ this.labelSum.TabIndex = 5;
+ this.labelSum.Text = "Сумма:";
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(247, 132);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(75, 23);
+ this.buttonSave.TabIndex = 6;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(345, 132);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(75, 23);
+ this.buttonCancel.TabIndex = 7;
+ this.buttonCancel.Text = "Отменить";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // FormCreateOrder
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(450, 167);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.labelSum);
+ this.Controls.Add(this.labelCount);
+ this.Controls.Add(this.labelPackage);
+ this.Controls.Add(this.textBoxSum);
+ this.Controls.Add(this.textBoxCount);
+ this.Controls.Add(this.comboBoxPackage);
+ this.Name = "FormCreateOrder";
+ this.Text = "Заказ";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+ this.Load += new System.EventHandler(this.FormCreateOrder_Load);
+
+ }
+
+ #endregion
+
+ private ComboBox comboBoxPackage;
+ private TextBox textBoxCount;
+ private TextBox textBoxSum;
+ private Label labelPackage;
+ private Label labelCount;
+ private Label labelSum;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/FormCreateOrder.cs b/SoftwareInstallation/FormCreateOrder.cs
new file mode 100644
index 0000000..7767d69
--- /dev/null
+++ b/SoftwareInstallation/FormCreateOrder.cs
@@ -0,0 +1,128 @@
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
+using AbstractSoftwareInstallationContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+namespace SoftwareInstallationView
+{
+ public partial class FormCreateOrder : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IPackageLogic _logicP;
+ private readonly IOrderLogic _logicO;
+ public FormCreateOrder(ILogger logger, IPackageLogic logicP, IOrderLogic logicO)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicP = logicP;
+ _logicO = logicO;
+ LoadData();
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка пакетов для заказа");
+ try
+ {
+ var list = _logicP.ReadList(null);
+ if (list != null)
+ {
+ comboBoxPackage.DisplayMember = "PackageName";
+ comboBoxPackage.ValueMember = "Id";
+ comboBoxPackage.DataSource = list;
+ comboBoxPackage.SelectedItem = null;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки пакетов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void FormCreateOrder_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void CalcSum()
+ {
+ if (comboBoxPackage.SelectedValue != null &&
+ !string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ try
+ {
+ int id = Convert.ToInt32(comboBoxPackage.SelectedValue);
+ var product = _logicP.ReadElement(new PackageSearchModel
+ {
+ Id = id
+ });
+ int count = Convert.ToInt32(textBoxCount.Text);
+ textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
+ _logger.LogInformation("Расчет суммы заказа");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка расчета суммы заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+
+ }
+ private void TextBoxCount_TextChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+ private void ComboBoxProduct_SelectedIndexChanged(object sender,
+ EventArgs e)
+ {
+ CalcSum();
+ }
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxPackage.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите изделие", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Создание заказа");
+ try
+ {
+ var operationResult = _logicO.CreateOrder(new OrderBindingModel
+ {
+ PackageId = Convert.ToInt32(comboBoxPackage.SelectedValue),
+ Count = Convert.ToInt32(textBoxCount.Text),
+ Sum = Convert.ToDouble(textBoxSum.Text)
+ });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка создания заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+
+ }
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+
+ }
+
+}
diff --git a/SoftwareInstallation/FormCreateOrder.resx b/SoftwareInstallation/FormCreateOrder.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SoftwareInstallation/FormCreateOrder.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/SoftwareInstallation/FormMain.Designer.cs b/SoftwareInstallation/FormMain.Designer.cs
new file mode 100644
index 0000000..58ce484
--- /dev/null
+++ b/SoftwareInstallation/FormMain.Designer.cs
@@ -0,0 +1,174 @@
+namespace SoftwareInstallationView
+{
+ partial class FormMain
+ {
+ ///
+ /// 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.dataGridView = new System.Windows.Forms.DataGridView();
+ this.buttonCreateOrder = new System.Windows.Forms.Button();
+ this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
+ this.buttonOrderReady = new System.Windows.Forms.Button();
+ this.buttonIssuedOrder = new System.Windows.Forms.Button();
+ this.buttonRef = new System.Windows.Forms.Button();
+ this.menuStrip1 = new System.Windows.Forms.MenuStrip();
+ this.guideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.packageToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
+ this.storageToolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.menuStrip1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(1, 31);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowTemplate.Height = 25;
+ this.dataGridView.Size = new System.Drawing.Size(602, 230);
+ this.dataGridView.TabIndex = 0;
+ //
+ // buttonCreateOrder
+ //
+ this.buttonCreateOrder.Location = new System.Drawing.Point(628, 31);
+ this.buttonCreateOrder.Name = "buttonCreateOrder";
+ this.buttonCreateOrder.Size = new System.Drawing.Size(153, 23);
+ this.buttonCreateOrder.TabIndex = 2;
+ this.buttonCreateOrder.Text = "Создать заказ";
+ this.buttonCreateOrder.UseVisualStyleBackColor = true;
+ this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click);
+ //
+ // buttonTakeOrderInWork
+ //
+ this.buttonTakeOrderInWork.Location = new System.Drawing.Point(628, 75);
+ this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
+ this.buttonTakeOrderInWork.Size = new System.Drawing.Size(153, 23);
+ this.buttonTakeOrderInWork.TabIndex = 3;
+ this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
+ this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
+ this.buttonTakeOrderInWork.Click += new System.EventHandler(this.buttonTakeOrderInWork_Click);
+ //
+ // buttonOrderReady
+ //
+ this.buttonOrderReady.Location = new System.Drawing.Point(628, 123);
+ this.buttonOrderReady.Name = "buttonOrderReady";
+ this.buttonOrderReady.Size = new System.Drawing.Size(153, 23);
+ this.buttonOrderReady.TabIndex = 4;
+ this.buttonOrderReady.Text = "Заказ готов";
+ this.buttonOrderReady.UseVisualStyleBackColor = true;
+ this.buttonOrderReady.Click += new System.EventHandler(this.buttonOrderReady_Click);
+ //
+ // buttonIssuedOrder
+ //
+ this.buttonIssuedOrder.Location = new System.Drawing.Point(628, 171);
+ this.buttonIssuedOrder.Name = "buttonIssuedOrder";
+ this.buttonIssuedOrder.Size = new System.Drawing.Size(153, 23);
+ this.buttonIssuedOrder.TabIndex = 5;
+ this.buttonIssuedOrder.Text = "Заказ принят";
+ this.buttonIssuedOrder.UseVisualStyleBackColor = true;
+ this.buttonIssuedOrder.Click += new System.EventHandler(this.buttonIssuedOrder_Click);
+ //
+ // buttonRef
+ //
+ this.buttonRef.Location = new System.Drawing.Point(628, 219);
+ this.buttonRef.Name = "buttonRef";
+ this.buttonRef.Size = new System.Drawing.Size(153, 23);
+ this.buttonRef.TabIndex = 6;
+ this.buttonRef.Text = "Обновить список";
+ this.buttonRef.UseVisualStyleBackColor = true;
+ this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click);
+ //
+ // menuStrip1
+ //
+ this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.guideToolStripMenuItem});
+ this.menuStrip1.Location = new System.Drawing.Point(0, 0);
+ this.menuStrip1.Name = "menuStrip1";
+ this.menuStrip1.Size = new System.Drawing.Size(803, 24);
+ this.menuStrip1.TabIndex = 1;
+ this.menuStrip1.Text = "menuStrip1";
+ //
+ // guideToolStripMenuItem
+ //
+ this.guideToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.packageToolStripMenuItem2,
+ this.storageToolStripMenuItem3});
+ this.guideToolStripMenuItem.Name = "guideToolStripMenuItem";
+ this.guideToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
+ this.guideToolStripMenuItem.Text = "Справочники";
+ //
+ // packageToolStripMenuItem2
+ //
+ this.packageToolStripMenuItem2.Name = "packageToolStripMenuItem2";
+ this.packageToolStripMenuItem2.Size = new System.Drawing.Size(180, 22);
+ this.packageToolStripMenuItem2.Text = "Пакеты";
+ this.packageToolStripMenuItem2.Click += new System.EventHandler(this.packageToolStripMenuItem_Click);
+ //
+ // storageToolStripMenuItem3
+ //
+ this.storageToolStripMenuItem3.Name = "storageToolStripMenuItem3";
+ this.storageToolStripMenuItem3.Size = new System.Drawing.Size(180, 22);
+ this.storageToolStripMenuItem3.Text = "ПО";
+ this.storageToolStripMenuItem3.Click += new System.EventHandler(this.softwareToolStripMenuItem_Click);
+ //
+ // FormMain
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(803, 263);
+ this.Controls.Add(this.buttonRef);
+ this.Controls.Add(this.buttonIssuedOrder);
+ this.Controls.Add(this.buttonOrderReady);
+ this.Controls.Add(this.buttonTakeOrderInWork);
+ this.Controls.Add(this.buttonCreateOrder);
+ this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.menuStrip1);
+ this.MainMenuStrip = this.menuStrip1;
+ this.Name = "FormMain";
+ this.Text = "Магазин программного обеспечения";
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.menuStrip1.ResumeLayout(false);
+ this.menuStrip1.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+ this.Load += new System.EventHandler(this.FormMain_Load);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonCreateOrder;
+ private Button buttonTakeOrderInWork;
+ private Button buttonOrderReady;
+ private Button buttonIssuedOrder;
+ private Button buttonRef;
+ private MenuStrip menuStrip1;
+ private ToolStripMenuItem guideToolStripMenuItem;
+ private ToolStripMenuItem packageToolStripMenuItem2;
+ private ToolStripMenuItem storageToolStripMenuItem3;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/FormMain.cs b/SoftwareInstallation/FormMain.cs
new file mode 100644
index 0000000..e200157
--- /dev/null
+++ b/SoftwareInstallation/FormMain.cs
@@ -0,0 +1,160 @@
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using SoftwareInstallation;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace SoftwareInstallationView
+{
+ public partial class FormMain : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderLogic _orderLogic;
+
+ public FormMain(ILogger logger, IOrderLogic orderLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _orderLogic = orderLogic;
+ }
+ private void FormMain_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка заказов");
+ try
+ {
+ var list = _orderLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["PackageId"].Visible = false;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки заказов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+
+ private void buttonCreateOrder_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
+ if (service is FormCreateOrder form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+ private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
+ try
+ {
+ var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка передачи заказа в работу");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void buttonOrderReady_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'",
+ id);
+ try
+ {
+ var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
+ { Id = id });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о готовности заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void buttonIssuedOrder_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
+ try
+ {
+ var operationResult = _orderLogic.DeliveryOrder(new
+ OrderBindingModel
+ { Id = id });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ _logger.LogInformation("Заказ №{id} выдан", id);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void softwareToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormSoftwares));
+ if (service is FormSoftwares form)
+ {
+ form.ShowDialog();
+ }
+ }
+ private void packageToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPackage));
+ if (service is FormPackage form)
+ {
+ form.ShowDialog();
+ }
+ }
+ private void buttonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ }
+}
diff --git a/SoftwareInstallation/FormMain.resx b/SoftwareInstallation/FormMain.resx
new file mode 100644
index 0000000..938108a
--- /dev/null
+++ b/SoftwareInstallation/FormMain.resx
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/SoftwareInstallation/FormPackage.Designer.cs b/SoftwareInstallation/FormPackage.Designer.cs
new file mode 100644
index 0000000..edd7ce3
--- /dev/null
+++ b/SoftwareInstallation/FormPackage.Designer.cs
@@ -0,0 +1,225 @@
+namespace SoftwareInstallationView
+{
+ partial class FormPackage
+ {
+ ///
+ /// 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.textBoxName = new System.Windows.Forms.TextBox();
+ this.textBoxPrice = new System.Windows.Forms.TextBox();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ColumnSoftware = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.groupBoxSoftware = new System.Windows.Forms.GroupBox();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonEdit = new System.Windows.Forms.Button();
+ this.buttonDelete = new System.Windows.Forms.Button();
+ this.buttonUpdate = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.labelName = new System.Windows.Forms.Label();
+ this.labelPrice = new System.Windows.Forms.Label();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.groupBoxSoftware.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // textBox1
+ //
+ this.textBoxName.Location = new System.Drawing.Point(131, 12);
+ this.textBoxName.Name = "textBox1";
+ this.textBoxName.Size = new System.Drawing.Size(343, 23);
+ this.textBoxName.TabIndex = 0;
+ //
+ // textBox2
+ //
+ this.textBoxPrice.Location = new System.Drawing.Point(131, 57);
+ this.textBoxPrice.Name = "textBox2";
+ this.textBoxPrice.Size = new System.Drawing.Size(174, 23);
+ this.textBoxPrice.TabIndex = 1;
+ //
+ // dataGridView1
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.ColumnId,
+ this.ColumnSoftware,
+ this.ColumnCount});
+ this.dataGridView.Location = new System.Drawing.Point(6, 22);
+ this.dataGridView.Name = "dataGridView1";
+ this.dataGridView.RowTemplate.Height = 25;
+ this.dataGridView.Size = new System.Drawing.Size(444, 299);
+ this.dataGridView.TabIndex = 2;
+ //
+ // ColumnId
+ //
+ this.ColumnId.HeaderText = "Id";
+ this.ColumnId.Name = "ColumnId";
+ this.ColumnId.Visible = false;
+ //
+ // ColumnSoftware
+ //
+ this.ColumnSoftware.HeaderText = "ПО";
+ this.ColumnSoftware.Name = "ColumnSoftware";
+ this.ColumnSoftware.Width = 300;
+ //
+ // ColumnCount
+ //
+ this.ColumnCount.HeaderText = "Количество";
+ this.ColumnCount.Name = "ColumnCount";
+ //
+ // groupBoxSoftware
+ //
+ this.groupBoxSoftware.Controls.Add(this.buttonUpdate);
+ this.groupBoxSoftware.Controls.Add(this.buttonDelete);
+ this.groupBoxSoftware.Controls.Add(this.dataGridView);
+ this.groupBoxSoftware.Controls.Add(this.buttonEdit);
+ this.groupBoxSoftware.Controls.Add(this.buttonAdd);
+ this.groupBoxSoftware.Location = new System.Drawing.Point(21, 105);
+ this.groupBoxSoftware.Name = "groupBoxSoftware";
+ this.groupBoxSoftware.Size = new System.Drawing.Size(586, 327);
+ this.groupBoxSoftware.TabIndex = 3;
+ this.groupBoxSoftware.TabStop = false;
+ this.groupBoxSoftware.Text = "ПО";
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(473, 22);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(98, 29);
+ this.buttonAdd.TabIndex = 0;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
+ //
+ // buttonEdit
+ //
+ this.buttonEdit.Location = new System.Drawing.Point(473, 75);
+ this.buttonEdit.Name = "buttonEdit";
+ this.buttonEdit.Size = new System.Drawing.Size(98, 31);
+ this.buttonEdit.TabIndex = 1;
+ this.buttonEdit.Text = "Изменить";
+ this.buttonEdit.UseVisualStyleBackColor = true;
+ this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click);
+ //
+ // buttonDelete
+ //
+ this.buttonDelete.Location = new System.Drawing.Point(473, 135);
+ this.buttonDelete.Name = "buttonDelete";
+ this.buttonDelete.Size = new System.Drawing.Size(98, 31);
+ this.buttonDelete.TabIndex = 3;
+ this.buttonDelete.Text = "Удалить";
+ this.buttonDelete.UseVisualStyleBackColor = true;
+ this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
+ //
+ // buttonUpdate
+ //
+ this.buttonUpdate.Location = new System.Drawing.Point(473, 194);
+ this.buttonUpdate.Name = "buttonUpdate";
+ this.buttonUpdate.Size = new System.Drawing.Size(98, 29);
+ this.buttonUpdate.TabIndex = 4;
+ this.buttonUpdate.Text = "Обновить";
+ this.buttonUpdate.UseVisualStyleBackColor = true;
+ this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(376, 438);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(98, 23);
+ this.buttonSave.TabIndex = 5;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(494, 438);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(98, 23);
+ this.buttonCancel.TabIndex = 6;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // labelName
+ //
+ this.labelName.AutoSize = true;
+ this.labelName.Location = new System.Drawing.Point(55, 15);
+ this.labelName.Name = "labelName";
+ this.labelName.Size = new System.Drawing.Size(62, 15);
+ this.labelName.TabIndex = 7;
+ this.labelName.Text = "Название:";
+ //
+ // labelPrice
+ //
+ this.labelPrice.AutoSize = true;
+ this.labelPrice.Location = new System.Drawing.Point(55, 60);
+ this.labelPrice.Name = "labelPrice";
+ this.labelPrice.Size = new System.Drawing.Size(70, 15);
+ this.labelPrice.TabIndex = 8;
+ this.labelPrice.Text = "Стоимость:";
+ //
+ // FormPackage
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(633, 472);
+ this.Controls.Add(this.labelPrice);
+ this.Controls.Add(this.labelName);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.textBoxPrice);
+ this.Controls.Add(this.textBoxName);
+ this.Controls.Add(this.groupBoxSoftware);
+ this.Name = "FormPackage";
+ this.Text = "Пакет";
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.groupBoxSoftware.ResumeLayout(false);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private TextBox textBoxName;
+ private TextBox textBoxPrice;
+ private DataGridView dataGridView;
+ private DataGridViewTextBoxColumn ColumnId;
+ private DataGridViewTextBoxColumn ColumnSoftware;
+ private DataGridViewTextBoxColumn ColumnCount;
+ private GroupBox groupBoxSoftware;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonEdit;
+ private Button buttonAdd;
+ private Button buttonSave;
+ private Button buttonCancel;
+ private Label labelName;
+ private Label labelPrice;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/FormPackage.cs b/SoftwareInstallation/FormPackage.cs
new file mode 100644
index 0000000..92bb6c0
--- /dev/null
+++ b/SoftwareInstallation/FormPackage.cs
@@ -0,0 +1,224 @@
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
+using AbstractSoftwareInstallationContracts.SearchModels;
+using AbstractSoftwareInstallationDataModels.Models;
+using Microsoft.Extensions.Logging;
+using SoftwareInstallation;
+
+namespace SoftwareInstallationView
+{
+ public partial class FormPackage : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IPackageLogic _logic;
+ private int? _id;
+ private Dictionary _packageSoftwares;
+ public int Id { set { _id = value; } }
+
+ public FormPackage(ILogger logger, IPackageLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _packageSoftwares = new Dictionary();
+ }
+ private void FormPackage_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Загрузка ПО");
+ try
+ {
+ var view = _logic.ReadElement(new PackageSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.PackageName;
+ textBoxPrice.Text = view.Price.ToString();
+ _packageSoftwares = view.PackageSoftware ?? new Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки ПО");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка ПО пакета");
+
+ try
+ {
+ if (_packageSoftwares != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var pc in _packageSoftwares)
+ {
+ dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.SoftwareName, pc.Value.Item2 });
+ }
+ textBoxPrice.Text = CalcPrice().ToString();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки ПО пакета");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPackageSoftware));
+
+ if (service is FormPackageSoftware form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.SoftwareModel == null)
+ {
+ return;
+ }
+
+ _logger.LogInformation("Добавление нового ПО: { SoftwareName} - { Count}", form.SoftwareModel.SoftwareName, form.Count);
+
+ if (_packageSoftwares.ContainsKey(form.Id))
+ {
+ _packageSoftwares[form.Id] = (form.SoftwareModel, form.Count);
+ }
+
+ else
+ {
+ _packageSoftwares.Add(form.Id, (form.SoftwareModel, form.Count));
+ }
+
+ LoadData();
+ }
+ }
+ }
+
+ private void buttonEdit_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPackageSoftware));
+
+ if (service is FormPackageSoftware form)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
+ form.Id = id;
+ form.Count = _packageSoftwares[id].Item2;
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.SoftwareModel == null)
+ {
+ return;
+ }
+
+ _logger.LogInformation("Изменение ПО: { SoftwareName} - { Count}", form.SoftwareModel.SoftwareName, form.Count);
+ _packageSoftwares[form.Id] = (form.SoftwareModel, form.Count);
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void buttonDelete_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ try
+ {
+ _logger.LogInformation("Удаление ПО: { SoftwareName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value);
+ _packageSoftwares?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ LoadData();
+ }
+ }
+ }
+
+ private void buttonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (string.IsNullOrEmpty(textBoxPrice.Text))
+ {
+ MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (_packageSoftwares == null || _packageSoftwares.Count == 0)
+ {
+ MessageBox.Show("Заполните ПО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Сохранение пакета");
+
+ try
+ {
+ var model = new PackageBindingModel
+ {
+ Id = _id ?? 0,
+ PackageName = textBoxName.Text,
+ Price = Convert.ToDouble(textBoxPrice.Text),
+ PackageSoftware = _packageSoftwares
+ };
+
+ var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения пакета");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+
+ }
+ private double CalcPrice()
+ {
+ double price = 0;
+
+ foreach (var elem in _packageSoftwares)
+ {
+ price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
+ }
+
+ return Math.Round(price * 1.1, 2);
+ }
+ }
+}
diff --git a/SoftwareInstallation/FormPackage.resx b/SoftwareInstallation/FormPackage.resx
new file mode 100644
index 0000000..f9d939b
--- /dev/null
+++ b/SoftwareInstallation/FormPackage.resx
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
\ No newline at end of file
diff --git a/SoftwareInstallation/FormPackageSoftware.Designer.cs b/SoftwareInstallation/FormPackageSoftware.Designer.cs
new file mode 100644
index 0000000..e6e5ead
--- /dev/null
+++ b/SoftwareInstallation/FormPackageSoftware.Designer.cs
@@ -0,0 +1,119 @@
+namespace SoftwareInstallationView
+{
+ partial class FormPackageSoftware
+ {
+ ///
+ /// 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.textBox1 = new System.Windows.Forms.TextBox();
+ this.comboBoxSoftware = new System.Windows.Forms.ComboBox();
+ this.labelSoftware = new System.Windows.Forms.Label();
+ this.labelCount = new System.Windows.Forms.Label();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // textBox1
+ //
+ this.textBox1.Location = new System.Drawing.Point(101, 65);
+ this.textBox1.Name = "textBox1";
+ this.textBox1.Size = new System.Drawing.Size(273, 23);
+ this.textBox1.TabIndex = 0;
+ //
+ // comboBoxSoftware
+ //
+ this.comboBoxSoftware.FormattingEnabled = true;
+ this.comboBoxSoftware.Location = new System.Drawing.Point(101, 24);
+ this.comboBoxSoftware.Name = "comboBoxSoftware";
+ this.comboBoxSoftware.Size = new System.Drawing.Size(273, 23);
+ this.comboBoxSoftware.TabIndex = 1;
+ //
+ // labelSoftware
+ //
+ this.labelSoftware.AutoSize = true;
+ this.labelSoftware.Location = new System.Drawing.Point(20, 27);
+ this.labelSoftware.Name = "labelSoftware";
+ this.labelSoftware.Size = new System.Drawing.Size(28, 15);
+ this.labelSoftware.TabIndex = 2;
+ this.labelSoftware.Text = "ПО:";
+ //
+ // labelCount
+ //
+ this.labelCount.AutoSize = true;
+ this.labelCount.Location = new System.Drawing.Point(20, 68);
+ this.labelCount.Name = "labelCount";
+ this.labelCount.Size = new System.Drawing.Size(75, 15);
+ this.labelCount.TabIndex = 3;
+ this.labelCount.Text = "Количество:";
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(195, 103);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(75, 27);
+ this.buttonSave.TabIndex = 4;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(299, 103);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(75, 27);
+ this.buttonCancel.TabIndex = 5;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // FormPackageSoftware
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(403, 142);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.labelCount);
+ this.Controls.Add(this.labelSoftware);
+ this.Controls.Add(this.comboBoxSoftware);
+ this.Controls.Add(this.textBox1);
+ this.Name = "FormPackageSoftware";
+ this.Text = "ПО пакета";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private TextBox textBox1;
+ private ComboBox comboBoxSoftware;
+ private Label labelSoftware;
+ private Label labelCount;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/FormPackageSoftware.cs b/SoftwareInstallation/FormPackageSoftware.cs
new file mode 100644
index 0000000..0374af1
--- /dev/null
+++ b/SoftwareInstallation/FormPackageSoftware.cs
@@ -0,0 +1,84 @@
+using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
+using AbstractSoftwareInstallationContracts.ViewModels;
+using AbstractSoftwareInstallationDataModels.Models;
+
+namespace SoftwareInstallationView
+{
+ public partial class FormPackageSoftware : Form
+ {
+ private readonly List? _list;
+ public int Id
+ {
+ get
+ {
+ return Convert.ToInt32(comboBoxSoftware.SelectedValue);
+ }
+ set
+ {
+ comboBoxSoftware.SelectedValue = value;
+ }
+ }
+ public ISoftwareModel? SoftwareModel
+ {
+ get
+ {
+ if (_list == null)
+ {
+ return null;
+ }
+ foreach (var elem in _list)
+ {
+ if (elem.Id == Id)
+ {
+ return elem;
+ }
+ }
+ return null;
+ }
+ }
+
+ public int Count
+ {
+ get { return Convert.ToInt32(textBox1.Text); }
+ set
+ { textBox1.Text = value.ToString(); }
+ }
+
+ public FormPackageSoftware(ISoftwareLogic logic)
+ {
+ InitializeComponent();
+ _list = logic.ReadList(null);
+ if (_list != null)
+ {
+ comboBoxSoftware.DisplayMember = "SoftwareName";
+ comboBoxSoftware.ValueMember = "Id";
+ comboBoxSoftware.DataSource = _list;
+ comboBoxSoftware.SelectedItem = null;
+ }
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBox1.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxSoftware.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите компонент", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+
+ }
+}
diff --git a/SoftwareInstallation/FormPackageSoftware.resx b/SoftwareInstallation/FormPackageSoftware.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SoftwareInstallation/FormPackageSoftware.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/SoftwareInstallation/FormPackages.Designer.cs b/SoftwareInstallation/FormPackages.Designer.cs
new file mode 100644
index 0000000..77499ec
--- /dev/null
+++ b/SoftwareInstallation/FormPackages.Designer.cs
@@ -0,0 +1,123 @@
+namespace SoftwareInstallationView
+{
+ partial class FormPackages
+ {
+ ///
+ /// 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.dataGridView = new System.Windows.Forms.DataGridView();
+ this.buttonUpdate = new System.Windows.Forms.Button();
+ this.buttonDelete = new System.Windows.Forms.Button();
+ this.buttonEdit = new System.Windows.Forms.Button();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.ColumnId});
+ this.dataGridView.Location = new System.Drawing.Point(1, 1);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowTemplate.Height = 25;
+ this.dataGridView.Size = new System.Drawing.Size(445, 373);
+ this.dataGridView.TabIndex = 10;
+ //
+ // buttonUpdate
+ //
+ this.buttonUpdate.Location = new System.Drawing.Point(461, 193);
+ this.buttonUpdate.Name = "buttonUpdate";
+ this.buttonUpdate.Size = new System.Drawing.Size(97, 30);
+ this.buttonUpdate.TabIndex = 9;
+ this.buttonUpdate.Text = "Обновить";
+ this.buttonUpdate.UseVisualStyleBackColor = true;
+ //
+ // buttonDelete
+ //
+ this.buttonDelete.Location = new System.Drawing.Point(461, 135);
+ this.buttonDelete.Name = "buttonDelete";
+ this.buttonDelete.Size = new System.Drawing.Size(97, 30);
+ this.buttonDelete.TabIndex = 8;
+ this.buttonDelete.Text = "Удалить";
+ this.buttonDelete.UseVisualStyleBackColor = true;
+ //
+ // buttonEdit
+ //
+ this.buttonEdit.Location = new System.Drawing.Point(461, 79);
+ this.buttonEdit.Name = "buttonEdit";
+ this.buttonEdit.Size = new System.Drawing.Size(97, 30);
+ this.buttonEdit.TabIndex = 7;
+ this.buttonEdit.Text = "Изменить";
+ this.buttonEdit.UseVisualStyleBackColor = true;
+ this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click);
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(461, 22);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(97, 30);
+ this.buttonAdd.TabIndex = 6;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ //
+ // ColumnId
+ //
+ this.ColumnId.FillWeight = 200F;
+ this.ColumnId.HeaderText = "Id";
+ this.ColumnId.Name = "ColumnId";
+ this.ColumnId.Visible = false;
+ this.ColumnId.Width = 200;
+ //
+ // FormPackages
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(565, 374);
+ this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.buttonUpdate);
+ this.Controls.Add(this.buttonDelete);
+ this.Controls.Add(this.buttonEdit);
+ this.Controls.Add(this.buttonAdd);
+ this.Name = "FormPackages";
+ this.Text = "FormPackages";
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonEdit;
+ private Button buttonAdd;
+ private DataGridViewTextBoxColumn ColumnId;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/FormPackages.cs b/SoftwareInstallation/FormPackages.cs
new file mode 100644
index 0000000..978a305
--- /dev/null
+++ b/SoftwareInstallation/FormPackages.cs
@@ -0,0 +1,110 @@
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using SoftwareInstallation;
+
+namespace SoftwareInstallationView
+{
+ public partial class FormPackages : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IPackageLogic _logic;
+ public FormPackages(ILogger logger, IPackageLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void FormPackages_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns["PackageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["PackageSoftwares"].Visible = false;
+ }
+ _logger.LogInformation("Загрузка пакетов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки пакетов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPackage));
+
+ if (service is FormPackage form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ private void ButtonUpd_Click(object sender, EventArgs e)
+ {
+
+ }
+ private void ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Удаление изделия");
+
+ try
+ {
+ if (!_logic.Delete(new PackageBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void buttonEdit_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPackage));
+
+ if (service is FormPackage form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/SoftwareInstallation/FormPackages.resx b/SoftwareInstallation/FormPackages.resx
new file mode 100644
index 0000000..1f60a5e
--- /dev/null
+++ b/SoftwareInstallation/FormPackages.resx
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ True
+
+
\ No newline at end of file
diff --git a/SoftwareInstallation/FormSoftware.Designer.cs b/SoftwareInstallation/FormSoftware.Designer.cs
new file mode 100644
index 0000000..3fba4c6
--- /dev/null
+++ b/SoftwareInstallation/FormSoftware.Designer.cs
@@ -0,0 +1,118 @@
+namespace SoftwareInstallation
+{
+ partial class FormSoftware
+ {
+ ///
+ /// 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.textBoxName = new System.Windows.Forms.TextBox();
+ this.textBoxCost = new System.Windows.Forms.TextBox();
+ this.labelName = new System.Windows.Forms.Label();
+ this.labelCost = new System.Windows.Forms.Label();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // textBoxName
+ //
+ this.textBoxName.Location = new System.Drawing.Point(94, 28);
+ this.textBoxName.Name = "textBoxName";
+ this.textBoxName.Size = new System.Drawing.Size(316, 23);
+ this.textBoxName.TabIndex = 0;
+ //
+ // textBoxCost
+ //
+ this.textBoxCost.Location = new System.Drawing.Point(94, 76);
+ this.textBoxCost.Name = "textBoxCost";
+ this.textBoxCost.Size = new System.Drawing.Size(156, 23);
+ this.textBoxCost.TabIndex = 1;
+ //
+ // labelName
+ //
+ this.labelName.AutoSize = true;
+ this.labelName.Location = new System.Drawing.Point(29, 28);
+ this.labelName.Name = "labelName";
+ this.labelName.Size = new System.Drawing.Size(62, 15);
+ this.labelName.TabIndex = 2;
+ this.labelName.Text = "Название:";
+ //
+ // labelCost
+ //
+ this.labelCost.AutoSize = true;
+ this.labelCost.Location = new System.Drawing.Point(29, 76);
+ this.labelCost.Name = "labelCost";
+ this.labelCost.Size = new System.Drawing.Size(38, 15);
+ this.labelCost.TabIndex = 3;
+ this.labelCost.Text = "Цена:";
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(195, 115);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(103, 26);
+ this.buttonSave.TabIndex = 4;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(307, 115);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(103, 26);
+ this.buttonCancel.TabIndex = 5;
+ this.buttonCancel.Text = "Отменить";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // FormSoftware
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(441, 153);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.labelCost);
+ this.Controls.Add(this.labelName);
+ this.Controls.Add(this.textBoxCost);
+ this.Controls.Add(this.textBoxName);
+ this.Name = "FormSoftware";
+ this.Text = "Программное обеспечение";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private TextBox textBoxName;
+ private TextBox textBoxCost;
+ private Label labelName;
+ private Label labelCost;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/FormSoftware.cs b/SoftwareInstallation/FormSoftware.cs
new file mode 100644
index 0000000..95bf8d3
--- /dev/null
+++ b/SoftwareInstallation/FormSoftware.cs
@@ -0,0 +1,89 @@
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
+using AbstractSoftwareInstallationContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+namespace SoftwareInstallation
+{
+ public partial class FormSoftware : Form
+ {
+ private readonly ILogger _logger;
+ private readonly ISoftwareLogic _logic;
+ private int? _id;
+ public int Id { set { _id = value; } }
+ public FormSoftware(ILogger logger, ISoftwareLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void FormSoftware_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ try
+ {
+ _logger.LogInformation(" ");
+ var view = _logic.ReadElement(new SoftwareSearchModel
+ {
+ Id =
+ _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.SoftwareName;
+ textBoxCost.Text = view.Cost.ToString();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, " ");
+ MessageBox.Show(ex.Message, "", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show(" ", "",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation(" ");
+ try
+ {
+ var model = new SoftwareBindingModel
+ {
+ Id = _id ?? 0,
+ SoftwareName = textBoxName.Text,
+ Cost = Convert.ToDouble(textBoxCost.Text)
+ };
+ var operationResult = _id.HasValue ? _logic.Update(model) :
+ _logic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception(" . .");
+ }
+ MessageBox.Show(" ", "",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, " ");
+ MessageBox.Show(ex.Message, "", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+
+ }
+
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/FormSoftware.resx b/SoftwareInstallation/FormSoftware.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SoftwareInstallation/FormSoftware.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/SoftwareInstallation/FormSoftwares.Designer.cs b/SoftwareInstallation/FormSoftwares.Designer.cs
new file mode 100644
index 0000000..a1a85ce
--- /dev/null
+++ b/SoftwareInstallation/FormSoftwares.Designer.cs
@@ -0,0 +1,125 @@
+namespace SoftwareInstallationView
+{
+ partial class FormSoftwares
+ {
+ ///
+ /// 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.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonEdit = new System.Windows.Forms.Button();
+ this.buttonDelete = new System.Windows.Forms.Button();
+ this.buttonUpdate = new System.Windows.Forms.Button();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(461, 23);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(97, 30);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // buttonEdit
+ //
+ this.buttonEdit.Location = new System.Drawing.Point(461, 80);
+ this.buttonEdit.Name = "buttonEdit";
+ this.buttonEdit.Size = new System.Drawing.Size(97, 30);
+ this.buttonEdit.TabIndex = 2;
+ this.buttonEdit.Text = "Изменить";
+ this.buttonEdit.UseVisualStyleBackColor = true;
+ this.buttonEdit.Click += new System.EventHandler(this.ButtonRef_Click);
+ //
+ // buttonDelete
+ //
+ this.buttonDelete.Location = new System.Drawing.Point(461, 136);
+ this.buttonDelete.Name = "buttonDelete";
+ this.buttonDelete.Size = new System.Drawing.Size(97, 30);
+ this.buttonDelete.TabIndex = 3;
+ this.buttonDelete.Text = "Удалить";
+ this.buttonDelete.UseVisualStyleBackColor = true;
+ this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // buttonUpdate
+ //
+ this.buttonUpdate.Location = new System.Drawing.Point(461, 194);
+ this.buttonUpdate.Name = "buttonUpdate";
+ this.buttonUpdate.Size = new System.Drawing.Size(97, 30);
+ this.buttonUpdate.TabIndex = 4;
+ this.buttonUpdate.Text = "Обновить";
+ this.buttonUpdate.UseVisualStyleBackColor = true;
+ this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.ColumnId});
+ this.dataGridView.Location = new System.Drawing.Point(1, 2);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowTemplate.Height = 25;
+ this.dataGridView.Size = new System.Drawing.Size(445, 410);
+ this.dataGridView.TabIndex = 5;
+ //
+ // ColumnId
+ //
+ this.ColumnId.FillWeight = 200F;
+ this.ColumnId.HeaderText = "Id";
+ this.ColumnId.Name = "ColumnId";
+ this.ColumnId.Visible = false;
+ this.ColumnId.Width = 200;
+ //
+ // FormSoftwares
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(581, 413);
+ this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.buttonUpdate);
+ this.Controls.Add(this.buttonDelete);
+ this.Controls.Add(this.buttonEdit);
+ this.Controls.Add(this.buttonAdd);
+ this.Name = "FormSoftwares";
+ this.Text = "Программные обеспечения";
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+ private Button buttonAdd;
+ private Button buttonEdit;
+ private Button buttonDelete;
+ private Button buttonUpdate;
+ private DataGridView dataGridView;
+ private DataGridViewTextBoxColumn ColumnId;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/FormSoftwares.cs b/SoftwareInstallation/FormSoftwares.cs
new file mode 100644
index 0000000..d0db248
--- /dev/null
+++ b/SoftwareInstallation/FormSoftwares.cs
@@ -0,0 +1,95 @@
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using SoftwareInstallation;
+
+namespace SoftwareInstallationView
+{
+ public partial class FormSoftwares : Form
+ {
+ public FormSoftwares(ILogger logger, ISoftwareLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ LoadData();
+ }
+ private readonly ILogger _logger;
+ private readonly ISoftwareLogic _logic;
+
+ private void FormSoftwares_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns["SoftwareName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ _logger.LogInformation("Загрузка компонентов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки компонентов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormSoftware));
+ if (service is FormSoftware form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ private void ButtonUpd_Click(object sender, EventArgs e)
+ {
+
+ }
+ private void ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ int id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Удаление ПО");
+ try
+ {
+ if (!_logic.Delete(new SoftwareBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении.Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления ПО");
+ MessageBox.Show(ex.Message, "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+
+}
diff --git a/SoftwareInstallation/FormSoftwares.resx b/SoftwareInstallation/FormSoftwares.resx
new file mode 100644
index 0000000..1f60a5e
--- /dev/null
+++ b/SoftwareInstallation/FormSoftwares.resx
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ True
+
+
\ No newline at end of file
diff --git a/SoftwareInstallation/Program.cs b/SoftwareInstallation/Program.cs
new file mode 100644
index 0000000..5f1471b
--- /dev/null
+++ b/SoftwareInstallation/Program.cs
@@ -0,0 +1,54 @@
+using AbstractOrderInstallationListImplement.Implements;
+using AbstractPackageInstallationListImplement.Implements;
+using AbstractSoftwareInstallationBusinessLogic;
+using AbstractSoftwareInstallationBusinessLogic.BusinessLogic;
+using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
+using AbstractSoftwareInstallationContracts.StoragesContracts;
+using AbstractSoftwareInstallationListImplement.Implements;
+using SoftwareInstallationView;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+
+namespace SoftwareInstallation
+{
+ internal static class Program
+ {
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ ApplicationConfiguration.Initialize();
+ var services = new ServiceCollection();
+ ConfigureServices(services);
+ _serviceProvider = services.BuildServiceProvider();
+ Application.Run(_serviceProvider.GetRequiredService());
+ }
+ private static void ConfigureServices(ServiceCollection services)
+ {
+ services.AddLogging(option =>
+ {
+ option.SetMinimumLevel(LogLevel.Information);
+ option.AddNLog("nlog.config");
+ });
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ }
+
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallation.csproj b/SoftwareInstallation/SoftwareInstallation.csproj
new file mode 100644
index 0000000..b57c89e
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation.csproj
@@ -0,0 +1,11 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallationView.csproj b/SoftwareInstallation/SoftwareInstallationView.csproj
new file mode 100644
index 0000000..3783142
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallationView.csproj
@@ -0,0 +1,22 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file