diff --git a/AbstractComputerDataModel/ComputerShopDataModels.csproj b/AbstractComputerDataModel/ComputerShopDataModels.csproj
new file mode 100644
index 0000000..895206e
--- /dev/null
+++ b/AbstractComputerDataModel/ComputerShopDataModels.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/AbstractComputerDataModel/Enums/OrderStatus.cs b/AbstractComputerDataModel/Enums/OrderStatus.cs
new file mode 100644
index 0000000..4e6f746
--- /dev/null
+++ b/AbstractComputerDataModel/Enums/OrderStatus.cs
@@ -0,0 +1,11 @@
+namespace ComputerShopDataModels.Enums
+{
+ public enum OrderStatus
+ {
+ Неизвестен = -1,
+ Принят = 0,
+ Выполняется = 1,
+ Готов = 2,
+ Выдан = 3
+ }
+}
\ No newline at end of file
diff --git a/AbstractComputerDataModel/Models/IComponentModel.cs b/AbstractComputerDataModel/Models/IComponentModel.cs
new file mode 100644
index 0000000..a04c804
--- /dev/null
+++ b/AbstractComputerDataModel/Models/IComponentModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopDataModels.Models
+{
+ public interface IComponentModel
+ {
+ string ComponentName { get; }
+ double Cost { get; }
+ }
+}
diff --git a/AbstractComputerDataModel/Models/IComputerModel.cs b/AbstractComputerDataModel/Models/IComputerModel.cs
new file mode 100644
index 0000000..9d24edd
--- /dev/null
+++ b/AbstractComputerDataModel/Models/IComputerModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopDataModels.Models
+{
+ public interface IComputerModel
+ {
+ string ComputerName { get; }
+ double Price { get; }
+ Dictionary ComputerComponents { get; }
+ }
+}
diff --git a/AbstractComputerDataModel/Models/IId.cs b/AbstractComputerDataModel/Models/IId.cs
new file mode 100644
index 0000000..4994ee2
--- /dev/null
+++ b/AbstractComputerDataModel/Models/IId.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopDataModels.Models
+{
+ public interface IId
+ {
+ string Id { get; }
+ }
+}
diff --git a/AbstractComputerDataModel/Models/IOrderModel.cs b/AbstractComputerDataModel/Models/IOrderModel.cs
new file mode 100644
index 0000000..7659783
--- /dev/null
+++ b/AbstractComputerDataModel/Models/IOrderModel.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ComputerShopDataModels.Enums;
+
+namespace ComputerShopDataModels.Models
+{
+ public interface IOrderModel
+ {
+ int ComputerId { get; }
+ int Count { get; }
+ double Sum { get; }
+ OrderStatus Status { get; }
+ DateTime DateCreate { get; }
+ DateTime? DateImplement { get; }
+ }
+}
diff --git a/ComputerShopBusinessLogic/BusinessLogics/ComponentLogic.cs b/ComputerShopBusinessLogic/BusinessLogics/ComponentLogic.cs
new file mode 100644
index 0000000..81c8908
--- /dev/null
+++ b/ComputerShopBusinessLogic/BusinessLogics/ComponentLogic.cs
@@ -0,0 +1,114 @@
+using ComputerShopContracts.BindingModels;
+using ComputerShopContracts.BusinessLogicsContracts;
+using ComputerShopContracts.SearchModels;
+using ComputerShopContracts.StoragesContracts;
+using ComputerShopContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Logging;
+
+namespace ComputerShopBusinessLogic.BusinessLogics
+{
+ public class ComponentLogic : IComponentLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IComponentStorage _componentStorage;
+ public ComponentLogic(ILogger logger, IComponentStorage componentStorage)
+ {
+ _logger = logger;
+ _componentStorage = componentStorage;
+ }
+ public List? ReadList(ComponentSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{ Id}", model?.ComponentName, model?.Id);
+ var list = model == null ? _componentStorage.GetFullList() :
+ _componentStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public ComponentViewModel? ReadElement(ComponentSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{ Id}", model.ComponentName, model.Id);
+ var element = _componentStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
+ }
+ public bool Create(ComponentBindingModel model)
+ {
+ CheckModel(model);
+ if (_componentStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(ComponentBindingModel model)
+ {
+ CheckModel(model);
+ if (_componentStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(ComponentBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_componentStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(ComponentBindingModel model, bool withParams =
+ true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.ComponentName))
+ {
+ throw new ArgumentNullException("Нет названия компонента", nameof(model.ComponentName));
+ }
+ if (model.Cost <= 0)
+ {
+ throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
+ }
+ _logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{ Cost}. Id: { Id} ", model.ComponentName, model.Cost, model.Id);
+ var element = _componentStorage.GetElement(new ComponentSearchModel
+ {
+ ComponentName = model.ComponentName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Компонент с таким названием уже есть");
+ }
+ }
+ }
+}
diff --git a/ComputerShopBusinessLogic/ComputerShopBusinessLogic.csproj b/ComputerShopBusinessLogic/ComputerShopBusinessLogic.csproj
new file mode 100644
index 0000000..b63d171
--- /dev/null
+++ b/ComputerShopBusinessLogic/ComputerShopBusinessLogic.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ComputerShopContracts/BindingModels/ComponentBindingModel.cs b/ComputerShopContracts/BindingModels/ComponentBindingModel.cs
new file mode 100644
index 0000000..2855d00
--- /dev/null
+++ b/ComputerShopContracts/BindingModels/ComponentBindingModel.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ComputerShopDataModels.Models;
+
+namespace ComputerShopContracts.BindingModels
+{
+ public class ComponentBindingModel : IComponentModel
+ {
+ public int Id { get; set; }
+ public string ComponentName { get; set; } = string.Empty;
+ public double Cost { get; set; }
+ }
+}
diff --git a/ComputerShopContracts/BindingModels/ComputerBindingModel.cs b/ComputerShopContracts/BindingModels/ComputerBindingModel.cs
new file mode 100644
index 0000000..766356a
--- /dev/null
+++ b/ComputerShopContracts/BindingModels/ComputerBindingModel.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ComputerShopDataModels.Models;
+
+namespace ComputerShopContracts.BindingModels
+{
+ public class ComputerBindingModel : IComputerModel
+ {
+ public int Id { get; set; }
+ public string ComputerName { get; set; } = string.Empty;
+ public double Price { get; set; }
+ public Dictionary ComputerComponents
+ {
+ get;
+ set;
+ } = new();
+ }
+}
diff --git a/ComputerShopContracts/BindingModels/OrderBindingModel.cs b/ComputerShopContracts/BindingModels/OrderBindingModel.cs
new file mode 100644
index 0000000..4d25f70
--- /dev/null
+++ b/ComputerShopContracts/BindingModels/OrderBindingModel.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ComputerShopDataModels.Models;
+using ComputerShopDataModels.Enums;
+
+namespace ComputerShopContracts.BindingModels
+{
+ public class OrderBindingModel : IOrderModel
+ {
+ public int Id { get; set; }
+ public int ComputerId { 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/ComputerShopContracts/BusinessLogicsContracts/IComponentLogic.cs b/ComputerShopContracts/BusinessLogicsContracts/IComponentLogic.cs
new file mode 100644
index 0000000..c143e6f
--- /dev/null
+++ b/ComputerShopContracts/BusinessLogicsContracts/IComponentLogic.cs
@@ -0,0 +1,20 @@
+using ComputerShopContracts.BindingModels;
+using ComputerShopContracts.SearchModels;
+using ComputerShopContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopContracts.BusinessLogicsContracts
+{
+ public interface IComponentLogic
+ {
+ List? ReadList(ComponentSearchModel? model);
+ ComponentViewModel? ReadElement(ComponentSearchModel model);
+ bool Create(ComponentBindingModel model);
+ bool Update(ComponentBindingModel model);
+ bool Delete(ComponentBindingModel model);
+ }
+}
diff --git a/ComputerShopContracts/BusinessLogicsContracts/IComputerLogic.cs b/ComputerShopContracts/BusinessLogicsContracts/IComputerLogic.cs
new file mode 100644
index 0000000..fb85d39
--- /dev/null
+++ b/ComputerShopContracts/BusinessLogicsContracts/IComputerLogic.cs
@@ -0,0 +1,20 @@
+using ComputerShopContracts.BindingModels;
+using ComputerShopContracts.SearchModels;
+using ComputerShopContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopContracts.BusinessLogicsContracts
+{
+ public interface IComputerLogic
+ {
+ List? ReadList(ComputerSearchModel? model);
+ ComputerViewModel? ReadElement(ComputerSearchModel model);
+ bool Create(ComputerBindingModel model);
+ bool Update(ComputerBindingModel model);
+ bool Delete(ComputerBindingModel model);
+ }
+}
diff --git a/ComputerShopContracts/BusinessLogicsContracts/IOrderLogic.cs b/ComputerShopContracts/BusinessLogicsContracts/IOrderLogic.cs
new file mode 100644
index 0000000..a17869c
--- /dev/null
+++ b/ComputerShopContracts/BusinessLogicsContracts/IOrderLogic.cs
@@ -0,0 +1,20 @@
+using ComputerShopContracts.BindingModels;
+using ComputerShopContracts.SearchModels;
+using ComputerShopContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopContracts.BusinessLogicsContracts
+{
+ internal 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/ComputerShopContracts/ComputerShopContracts.csproj b/ComputerShopContracts/ComputerShopContracts.csproj
new file mode 100644
index 0000000..f838e9c
--- /dev/null
+++ b/ComputerShopContracts/ComputerShopContracts.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ComputerShopContracts/SearchModels/ComponentSearchModel.cs b/ComputerShopContracts/SearchModels/ComponentSearchModel.cs
new file mode 100644
index 0000000..78421a7
--- /dev/null
+++ b/ComputerShopContracts/SearchModels/ComponentSearchModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopContracts.SearchModels
+{
+ public class ComponentSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ComponentName { get; set; }
+ }
+}
diff --git a/ComputerShopContracts/SearchModels/ComputerSearchModel.cs b/ComputerShopContracts/SearchModels/ComputerSearchModel.cs
new file mode 100644
index 0000000..6b6ef33
--- /dev/null
+++ b/ComputerShopContracts/SearchModels/ComputerSearchModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopContracts.SearchModels
+{
+ public class ComputerSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ComputerName { get; set; }
+ }
+}
diff --git a/ComputerShopContracts/SearchModels/OrderSearchModel.cs b/ComputerShopContracts/SearchModels/OrderSearchModel.cs
new file mode 100644
index 0000000..3265f29
--- /dev/null
+++ b/ComputerShopContracts/SearchModels/OrderSearchModel.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopContracts.SearchModels
+{
+ public class OrderSearchModel
+ {
+ public int? Id { get; set; }
+ }
+}
diff --git a/ComputerShopContracts/StoragesContracts/IComponentStorage.cs b/ComputerShopContracts/StoragesContracts/IComponentStorage.cs
new file mode 100644
index 0000000..9bb4eea
--- /dev/null
+++ b/ComputerShopContracts/StoragesContracts/IComponentStorage.cs
@@ -0,0 +1,21 @@
+using ComputerShopContracts.BindingModels;
+using ComputerShopContracts.SearchModels;
+using ComputerShopContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopContracts.StoragesContracts
+{
+ public interface IComponentStorage
+ {
+ List GetFullList();
+ List GetFilteredList(ComponentSearchModel model);
+ ComponentViewModel? GetElement(ComponentSearchModel model);
+ ComponentViewModel? Insert(ComponentBindingModel model);
+ ComponentViewModel? Update(ComponentBindingModel model);
+ ComponentViewModel? Delete(ComponentBindingModel model);
+ }
+}
diff --git a/ComputerShopContracts/StoragesContracts/IComputerStorage.cs b/ComputerShopContracts/StoragesContracts/IComputerStorage.cs
new file mode 100644
index 0000000..88a1587
--- /dev/null
+++ b/ComputerShopContracts/StoragesContracts/IComputerStorage.cs
@@ -0,0 +1,21 @@
+using ComputerShopContracts.BindingModels;
+using ComputerShopContracts.SearchModels;
+using ComputerShopContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopContracts.StoragesContracts
+{
+ public interface IComputerStorage
+ {
+ List GetFullList();
+ List GetFilteredList(ComputerSearchModel model);
+ ComputerViewModel? GetElement(ComputerSearchModel model);
+ ComputerViewModel? Insert(ComputerBindingModel model);
+ ComputerViewModel? Update(ComputerBindingModel model);
+ ComputerViewModel? Delete(ComputerBindingModel model);
+ }
+}
diff --git a/ComputerShopContracts/StoragesContracts/IOrderStorage.cs b/ComputerShopContracts/StoragesContracts/IOrderStorage.cs
new file mode 100644
index 0000000..a8d822f
--- /dev/null
+++ b/ComputerShopContracts/StoragesContracts/IOrderStorage.cs
@@ -0,0 +1,21 @@
+using ComputerShopContracts.BindingModels;
+using ComputerShopContracts.SearchModels;
+using ComputerShopContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopContracts.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/ComputerShopContracts/ViewModels/ComponentViewModel.cs b/ComputerShopContracts/ViewModels/ComponentViewModel.cs
new file mode 100644
index 0000000..661912e
--- /dev/null
+++ b/ComputerShopContracts/ViewModels/ComponentViewModel.cs
@@ -0,0 +1,19 @@
+using ComputerShopDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopContracts.ViewModels
+{
+ public class ComponentViewModel : IComponentModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название компонента")]
+ public string ComponentName { get; set; } = string.Empty;
+ [DisplayName("Цена")]
+ public double Cost { get; set; }
+ }
+}
diff --git a/ComputerShopContracts/ViewModels/ComputerViewModel.cs b/ComputerShopContracts/ViewModels/ComputerViewModel.cs
new file mode 100644
index 0000000..8022b33
--- /dev/null
+++ b/ComputerShopContracts/ViewModels/ComputerViewModel.cs
@@ -0,0 +1,24 @@
+using ComputerShopDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopContracts.ViewModels
+{
+ public class ComputerViewModel : IComputerModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название изделия")]
+ public string ComputerName { get; set; } = string.Empty;
+ [DisplayName("Цена")]
+ public double Price { get; set; }
+ public Dictionary ComputerComponents
+ {
+ get;
+ set;
+ } = new();
+ }
+}
diff --git a/ComputerShopContracts/ViewModels/OrderViewModel.cs b/ComputerShopContracts/ViewModels/OrderViewModel.cs
new file mode 100644
index 0000000..83f7f62
--- /dev/null
+++ b/ComputerShopContracts/ViewModels/OrderViewModel.cs
@@ -0,0 +1,30 @@
+using ComputerShopDataModels.Enums;
+using ComputerShopDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopContracts.ViewModels
+{
+ public class OrderViewModel : IOrderModel
+ {
+ [DisplayName("Номер")]
+ public int Id { get; set; }
+ public int ComputerId { get; set; }
+ [DisplayName("Изделие")]
+ public string ComputerName { 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/ComputerShopListImplement/ComputerShopListImplement.csproj b/ComputerShopListImplement/ComputerShopListImplement.csproj
new file mode 100644
index 0000000..5cf7fb2
--- /dev/null
+++ b/ComputerShopListImplement/ComputerShopListImplement.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/ComputerShopListImplement/Implements/ComponentStorage.cs b/ComputerShopListImplement/Implements/ComponentStorage.cs
new file mode 100644
index 0000000..43d3775
--- /dev/null
+++ b/ComputerShopListImplement/Implements/ComponentStorage.cs
@@ -0,0 +1,108 @@
+using ComputerShopContracts.BindingModels;
+using ComputerShopContracts.SearchModels;
+using ComputerShopContracts.StoragesContracts;
+using ComputerShopContracts.ViewModels;
+using ComputerShopListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopListImplement.Implements
+{
+ public class ComponentStorage : IComponentStorage
+ {
+ private readonly DataListSingleton _source;
+ public ComponentStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var component in _source.Components)
+ {
+ result.Add(component.GetViewModel);
+ }
+ return result;
+ }
+ public List GetFilteredList(ComponentSearchModel
+ model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.ComponentName))
+ {
+ return result;
+ }
+ foreach (var component in _source.Components)
+ {
+ if (component.ComponentName.Contains(model.ComponentName))
+ {
+ result.Add(component.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public ComponentViewModel? GetElement(ComponentSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var component in _source.Components)
+ {
+ if ((!string.IsNullOrEmpty(model.ComponentName) &&
+ component.ComponentName == model.ComponentName) ||
+ (model.Id.HasValue && component.Id == model.Id))
+ {
+ return component.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public ComponentViewModel? Insert(ComponentBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var component in _source.Components)
+ {
+ if (model.Id <= component.Id)
+ {
+ model.Id = component.Id + 1;
+ }
+ }
+ var newComponent = Component.Create(model);
+ if (newComponent == null)
+ {
+ return null;
+ }
+ _source.Components.Add(newComponent);
+ return newComponent.GetViewModel;
+ }
+ public ComponentViewModel? Update(ComponentBindingModel model)
+ {
+ foreach (var component in _source.Components)
+ {
+ if (component.Id == model.Id)
+ {
+ component.Update(model);
+ return component.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public ComponentViewModel? Delete(ComponentBindingModel model)
+ {
+ for (int i = 0; i < _source.Components.Count; ++i)
+ {
+ if (_source.Components[i].Id == model.Id)
+ {
+ var element = _source.Components[i];
+ _source.Components.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/ComputerShopListImplement/Models/Component.cs b/ComputerShopListImplement/Models/Component.cs
new file mode 100644
index 0000000..26058e4
--- /dev/null
+++ b/ComputerShopListImplement/Models/Component.cs
@@ -0,0 +1,47 @@
+using ComputerShopContracts.BindingModels;
+using ComputerShopContracts.ViewModels;
+using ComputerShopDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopListImplement.Models
+{
+ public class Component : IComponentModel
+ {
+ public int Id { get; private set; }
+ public string ComponentName { get; private set; } = string.Empty;
+ public double Cost { get; set; }
+ public static Component? Create(ComponentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Component()
+ {
+ Id = model.Id,
+ ComponentName = model.ComponentName,
+ Cost = model.Cost
+ };
+ }
+ public void Update(ComponentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ComponentName = model.ComponentName;
+ Cost = model.Cost;
+ }
+ public ComponentViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ComponentName = ComponentName,
+ Cost = Cost
+ };
+ }
+}
diff --git a/ComputerShopListImplement/Models/Computer.cs b/ComputerShopListImplement/Models/Computer.cs
new file mode 100644
index 0000000..3b788da
--- /dev/null
+++ b/ComputerShopListImplement/Models/Computer.cs
@@ -0,0 +1,54 @@
+using ComputerShopContracts.BindingModels;
+using ComputerShopContracts.ViewModels;
+using ComputerShopDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopListImplement.Models
+{
+ public class Computer : IComputerModel
+ {
+ public int Id { get; private set; }
+ public string ComputerName { get; private set; } = string.Empty;
+ public double Price { get; private set; }
+ public Dictionary ComputerComponents
+ {
+ get;
+ private set;
+ } = new Dictionary();
+ public static Computer? Create(ComputerBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Computer()
+ {
+ Id = model.Id,
+ ComputerName = model.ComputerName,
+ Price = model.Price,
+ ComputerComponents = model.ComputerComponents
+ };
+ }
+ public void Update(ComputerBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ ComputerName = model.ComputerName;
+ Price = model.Price;
+ ComputerComponents = model.ComputerComponents;
+ }
+ public ComputerViewModel GetViewModel => new()
+ {
+ Id = Id,
+ ComputerName = ComputerName,
+ Price = Price,
+ ComputerComponents = ComputerComponents
+ };
+ }
+}
diff --git a/ComputerShopListImplement/Models/DataListSingleton.cs b/ComputerShopListImplement/Models/DataListSingleton.cs
new file mode 100644
index 0000000..6335950
--- /dev/null
+++ b/ComputerShopListImplement/Models/DataListSingleton.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ComputerShopListImplement.Models
+{
+ public class DataListSingleton
+ {
+ private static DataListSingleton? _instance;
+ public List Components { get; set; }
+ //public List Orders { get; set; }
+ public List Computers { get; set; }
+ private DataListSingleton()
+ {
+ Components = new List();
+ //Orders = new List();
+ Computers = new List();
+ }
+ public static DataListSingleton GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new DataListSingleton();
+ }
+ return _instance;
+ }
+ }
+}
diff --git a/ComputersShop/ComputersShop.csproj b/ComputersShop/ComputersShop.csproj
index b57c89e..7173d64 100644
--- a/ComputersShop/ComputersShop.csproj
+++ b/ComputersShop/ComputersShop.csproj
@@ -8,4 +8,8 @@
enable
+
+
+
+
\ No newline at end of file
diff --git a/ComputersShop/ComputersShop.sln b/ComputersShop/ComputersShop.sln
index 80ed8e2..1bb85c8 100644
--- a/ComputersShop/ComputersShop.sln
+++ b/ComputersShop/ComputersShop.sln
@@ -5,6 +5,14 @@ VisualStudioVersion = 17.3.32819.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputersShop", "ComputersShop.csproj", "{7BE0F575-7A99-4161-BCD0-4F14E5AC7B95}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopDataModels", "..\AbstractComputerDataModel\ComputerShopDataModels.csproj", "{07BF1453-7129-45C4-AB54-AFC38F1E579D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopContracts", "..\ComputerShopContracts\ComputerShopContracts.csproj", "{4684F24F-29DC-496C-803F-0877E5100939}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopBusinessLogic", "..\ComputerShopBusinessLogic\ComputerShopBusinessLogic.csproj", "{8A6D08BB-449A-4C35-81CA-F82B6293D241}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopListImplement", "..\ComputerShopListImplement\ComputerShopListImplement.csproj", "{D632C3A7-3E0E-4B53-B2B4-696A9F6B8D38}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +23,22 @@ Global
{7BE0F575-7A99-4161-BCD0-4F14E5AC7B95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7BE0F575-7A99-4161-BCD0-4F14E5AC7B95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7BE0F575-7A99-4161-BCD0-4F14E5AC7B95}.Release|Any CPU.Build.0 = Release|Any CPU
+ {07BF1453-7129-45C4-AB54-AFC38F1E579D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {07BF1453-7129-45C4-AB54-AFC38F1E579D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {07BF1453-7129-45C4-AB54-AFC38F1E579D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {07BF1453-7129-45C4-AB54-AFC38F1E579D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4684F24F-29DC-496C-803F-0877E5100939}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4684F24F-29DC-496C-803F-0877E5100939}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4684F24F-29DC-496C-803F-0877E5100939}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4684F24F-29DC-496C-803F-0877E5100939}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8A6D08BB-449A-4C35-81CA-F82B6293D241}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8A6D08BB-449A-4C35-81CA-F82B6293D241}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8A6D08BB-449A-4C35-81CA-F82B6293D241}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8A6D08BB-449A-4C35-81CA-F82B6293D241}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D632C3A7-3E0E-4B53-B2B4-696A9F6B8D38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D632C3A7-3E0E-4B53-B2B4-696A9F6B8D38}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D632C3A7-3E0E-4B53-B2B4-696A9F6B8D38}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D632C3A7-3E0E-4B53-B2B4-696A9F6B8D38}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE