Compare commits

...

39 Commits

Author SHA1 Message Date
10ac29df01 логика сборки + логика покупок (подкорректированы purchaseBinding и BuildSearch) 2024-04-29 13:31:37 +04:00
06ec3952d3 логика работника (+ подкорректировала vendorSearchModel) и логика кладовщика (+ подкорректировала storekeeperSearchModel) 2024-04-29 13:17:43 +04:00
fe14f02d22 логика заказов 2024-04-29 12:18:09 +04:00
7f35ac9210 логика заказов 2024-04-29 12:17:45 +04:00
bekodeg
3e2d8d74a5 реализовал бизнес логику продукта и компонента 2024-04-28 20:59:05 +04:00
bekodeg
b1438de286 создал проект 2024-04-25 22:58:35 +04:00
bekodeg
e1c6fd8286 исправление ошибок 2024-04-25 22:38:28 +04:00
bekodeg
816fdcb208 исправление моделей viue 2024-04-25 22:20:09 +04:00
25d027fe30 Merge pull request 'BACKDEV-405' (#5) from BACKDEV-405 into dev
Reviewed-on: #5
2024-04-25 21:42:21 +04:00
bekodeg
1f922905b0 Merge branch 'BACKDEV-405' of https://git.is.ulstu.ru/bekodeg/ComputerHardwareStore_YouAreProgrammer into BACKDEV-405 2024-04-25 21:41:45 +04:00
03da9f0eda links 2024-04-25 21:41:31 +04:00
81907df9cf + links 2024-04-25 21:41:31 +04:00
9945ff4bb2 + vendor 2024-04-25 21:41:31 +04:00
9573c340ba business logicc ontracts 2024-04-25 21:41:31 +04:00
bekodeg
2023ac13c7 pull 2024-04-25 21:39:47 +04:00
b2c7cd9858 Merge pull request 'BACKDEV-401' (#7) from BACKDEV-401 into dev
Reviewed-on: #7
2024-04-25 17:47:17 +04:00
72ebbc11f9 Merge pull request 'BACKDEV-406' (#6) from BACKDEV-406 into dev
Reviewed-on: #6
2024-04-25 17:46:17 +04:00
930e4ed316 ссылки using 2024-04-24 19:21:18 +04:00
b48619623e Merge pull request 'BACKDEV-404' (#4) from BACKDEV-404 into dev
Reviewed-on: #4
2024-04-24 19:10:39 +04:00
bff0214329 Merge pull request 'searchmodels, нужно ли для коммента?' (#3) from BACKDEV-403 into dev
Reviewed-on: #3
2024-04-24 19:09:31 +04:00
8e96befcd6 links 2024-04-24 19:09:02 +04:00
14b3bbd20e + links 2024-04-24 19:08:37 +04:00
6b8a7a5d1b Merge pull request 'viewmodels' (#2) from BACKDEV-402 into dev
Reviewed-on: #2
2024-04-24 19:08:14 +04:00
40f96fe6c1 + vendor 2024-04-24 19:08:06 +04:00
65599c80a2 storage contract 2024-04-24 18:53:25 +04:00
c70fddda2c business logicc ontracts 2024-04-24 18:37:36 +04:00
d48b7ac0de bindingmodels 2024-04-18 16:47:15 +04:00
176b3bfc9d searchmodels, но нужно ли для коммента? 2024-04-18 15:32:47 +04:00
eee043483a Revert "searchmodels (не знаю, нужна ли модель для коммента, но сделала)"
This reverts commit 8b9ee21fb9.
2024-04-18 15:30:21 +04:00
8b9ee21fb9 searchmodels (не знаю, нужна ли модель для коммента, но сделала) 2024-04-18 15:29:39 +04:00
1a9edefdb9 viewmodels 2024-04-18 15:03:40 +04:00
bekodeg
f952809b0e добавил 2024-04-17 22:21:46 +04:00
bekodeg
09f64c788f создание проекта с контрактами 2024-04-17 22:06:25 +04:00
bekodeg
552c06f55e косячок 2024-04-17 22:06:08 +04:00
bekodeg
d7c2bc8e24 Merge branch 'dev' of https://git.is.ulstu.ru/bekodeg/ComputerHardwareStore_YouAreProgrammer into dev 2024-04-17 22:01:50 +04:00
bekodeg
a328d413fa создание проекта с контрактами 2024-04-17 22:01:38 +04:00
bekodeg
f6c69273df небольшие изменения 2024-04-17 21:54:05 +04:00
5bde6633c4 Merge pull request 'Создание моделей данных' (#1) from BACKDEV-401 into dev
Reviewed-on: #1
2024-04-17 21:47:28 +04:00
bekodeg
8049b51388 Создание моделей данных 2024-04-17 21:44:51 +04:00
62 changed files with 1574 additions and 0 deletions

View File

@ -5,6 +5,12 @@ VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerHardwareStore", "ComputerHardwareStore\ComputerHardwareStore.csproj", "{D5DDEE2B-A0C4-430B-B00E-452BA1AB3DDA}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerHardwareStore", "ComputerHardwareStore\ComputerHardwareStore.csproj", "{D5DDEE2B-A0C4-430B-B00E-452BA1AB3DDA}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerHardwareStoreDataModels", "ComputerHardwareStoreDataModels\ComputerHardwareStoreDataModels.csproj", "{48126915-C6D4-451C-BC88-39E3C50332B8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerHardwareStoreContracts", "ComputerHardwareStoreContracts\ComputerHardwareStoreContracts.csproj", "{5F394E21-2597-432B-AE73-BBAFD8D9F50E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerHardwareStoreBusinessLogic", "ComputerHardwareStoreBusinessLogic\ComputerHardwareStoreBusinessLogic.csproj", "{D32DEB60-AF40-46AF-8914-DC6A19BD66CD}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -15,6 +21,18 @@ Global
{D5DDEE2B-A0C4-430B-B00E-452BA1AB3DDA}.Debug|Any CPU.Build.0 = Debug|Any CPU {D5DDEE2B-A0C4-430B-B00E-452BA1AB3DDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5DDEE2B-A0C4-430B-B00E-452BA1AB3DDA}.Release|Any CPU.ActiveCfg = Release|Any CPU {D5DDEE2B-A0C4-430B-B00E-452BA1AB3DDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5DDEE2B-A0C4-430B-B00E-452BA1AB3DDA}.Release|Any CPU.Build.0 = Release|Any CPU {D5DDEE2B-A0C4-430B-B00E-452BA1AB3DDA}.Release|Any CPU.Build.0 = Release|Any CPU
{48126915-C6D4-451C-BC88-39E3C50332B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48126915-C6D4-451C-BC88-39E3C50332B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48126915-C6D4-451C-BC88-39E3C50332B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48126915-C6D4-451C-BC88-39E3C50332B8}.Release|Any CPU.Build.0 = Release|Any CPU
{5F394E21-2597-432B-AE73-BBAFD8D9F50E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F394E21-2597-432B-AE73-BBAFD8D9F50E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F394E21-2597-432B-AE73-BBAFD8D9F50E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F394E21-2597-432B-AE73-BBAFD8D9F50E}.Release|Any CPU.Build.0 = Release|Any CPU
{D32DEB60-AF40-46AF-8914-DC6A19BD66CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D32DEB60-AF40-46AF-8914-DC6A19BD66CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D32DEB60-AF40-46AF-8914-DC6A19BD66CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D32DEB60-AF40-46AF-8914-DC6A19BD66CD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -34,6 +34,27 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@ -0,0 +1,9 @@
namespace ComputerHardwareStore
{
internal static class Program
{
static void Main()
{
}
}
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection" version="8.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
</packages>

View File

@ -0,0 +1,113 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.BusinessLogicsContracts;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.StorageContracts;
using ComputerHardwareStoreContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
{
public class BuildLogic : IBuildLogic
{
private readonly ILogger _logger;
private readonly IBuildStorage _buildStorage;
public BuildLogic(ILogger<BuildLogic> logger, IBuildStorage buildStorage)
{
_logger = logger;
_buildStorage = buildStorage;
}
public List<BuildViewModel>? ReadList(BuildSearchModel? model)
{
_logger.LogInformation("ReadList Build. Name:{Name}. Id:{ Id}", model?.Name, model?.Id);
var list = model == null ? _buildStorage.GetFullList() :
_buildStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList Build return null list");
return null;
}
_logger.LogInformation("ReadList Build. Count:{Count}", list.Count);
return list;
}
public BuildViewModel? ReadElement(BuildSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement Build. Name:{Name}. Id:{ Id}", model.Name, model.Id);
var element = _buildStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement Build element not found");
return null;
}
_logger.LogInformation("ReadElement Build find. Id:{Id}", element.Id);
return element;
}
public bool Create(BuildBindingModel model)
{
CheckModel(model);
if (_buildStorage.Insert(model) == null)
{
_logger.LogWarning("Insert Build operation failed");
return false;
}
return true;
}
public bool Update(BuildBindingModel model)
{
CheckModel(model);
if (_buildStorage.Update(model) == null)
{
_logger.LogWarning("Update Build operation failed");
return false;
}
return true;
}
public bool Delete(BuildBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_buildStorage.Delete(model) == null)
{
_logger.LogWarning("Delete Build operation failed");
return false;
}
return true;
}
private void CheckModel(BuildBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет названия сборки", nameof(model.Name));
}
if (model.Price <= 0)
{
throw new ArgumentNullException("Цена сборки должна быть больше 0", nameof(model.Price));
}
var element = _buildStorage.GetElement(new BuildSearchModel
{
Name = model.Name
});
if (element != null)
{
throw new InvalidOperationException("Сборка с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,101 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.BusinessLogicsContracts;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.StorageContracts;
using ComputerHardwareStoreContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
{
public class CommentLogic : ICommentLogic
{
private readonly ILogger _logger;
private readonly ICommentStorage _commentStorage;
public CommentLogic(ILogger<CommentLogic> logger, ICommentStorage commentStorage)
{
_logger = logger;
_commentStorage = commentStorage;
}
public List<CommentViewModel>? ReadList(CommentSearchModel? model)
{
_logger.LogInformation("ReadList Comment. Date:{Date}. Id:{Id}", model?.Date, model?.Id);
var list = model == null ? _commentStorage.GetFullList() :
_commentStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList Comment return null list");
return null;
}
_logger.LogInformation("ReadList Comment. Count:{Count}", list.Count);
return list;
}
public CommentViewModel? ReadElement(CommentSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement Comment. Date:{Date}. Id:{ Id}", model.Date, model.Id);
var element = _commentStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement Comment element not found");
return null;
}
_logger.LogInformation("ReadElement Comment find. Id:{Id}", element.Id);
return element;
}
public bool Create(CommentBindingModel model)
{
CheckModel(model);
if (_commentStorage.Insert(model) == null)
{
_logger.LogWarning("Insert Comment operation failed");
return false;
}
return true;
}
public bool Update(CommentBindingModel model)
{
CheckModel(model);
if (_commentStorage.Update(model) == null)
{
_logger.LogWarning("Update Comment operation failed");
return false;
}
return true;
}
public bool Delete(CommentBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_commentStorage.Delete(model) == null)
{
_logger.LogWarning("Delete Comment operation failed");
return false;
}
return true;
}
private void CheckModel(CommentBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Date))
{
throw new ArgumentNullException("Нет даты у комментария", nameof(model.Date));
}
}
}
}

View File

@ -0,0 +1,113 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.BusinessLogicsContracts;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.StorageContracts;
using ComputerHardwareStoreContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
{
public class ComponentLogic : IComponentLogic
{
private readonly ILogger _logger;
private readonly IComponentStorage _componentStorage;
public ComponentLogic(ILogger<ComponentLogic> logger, IComponentStorage componentStorage)
{
_logger = logger;
_componentStorage = componentStorage;
}
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
{
_logger.LogInformation("ReadList Component. Name:{Name}. Id:{ Id}", model?.Name, model?.Id);
var list = model == null ? _componentStorage.GetFullList() :
_componentStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList Component return null list");
return null;
}
_logger.LogInformation("ReadList Component. Count:{Count}", list.Count);
return list;
}
public ComponentViewModel? ReadElement(ComponentSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement Component. Name:{Name}. Id:{ Id}", model.Name, model.Id);
var element = _componentStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement Component element not found");
return null;
}
_logger.LogInformation("ReadElement Component find. Id:{Id}", element.Id);
return element;
}
public bool Create(ComponentBindingModel model)
{
CheckModel(model);
if (_componentStorage.Insert(model) == null)
{
_logger.LogWarning("Insert Component operation failed");
return false;
}
return true;
}
public bool Update(ComponentBindingModel model)
{
CheckModel(model);
if (_componentStorage.Update(model) == null)
{
_logger.LogWarning("Update Component 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 Component 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.Name))
{
throw new ArgumentNullException("Нет названия компонента", nameof(model.Name));
}
if (model.Cost <= 0)
{
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
}
var element = _componentStorage.GetElement(new ComponentSearchModel
{
Name = model.Name
});
if (element != null)
{
throw new InvalidOperationException("Компонент с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,115 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.BusinessLogicsContracts;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.StorageContracts;
using ComputerHardwareStoreContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
{
public class OrderLogic : IOrderLogic
{
private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
{
_logger = logger;
_orderStorage = orderStorage;
}
public List<OrderViewModel>? 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.Неизвестен)
return false;
model.Status = OrderStatus.Принят;
if (_orderStorage.Insert(model) == null)
{
model.Status = OrderStatus.Неизвестен;
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool TakeOrderInWork(OrderBindingModel model)
{
return ToNextStatus(model, OrderStatus.Выполняется);
}
public bool FinishOrder(OrderBindingModel model)
{
return ToNextStatus(model, OrderStatus.Готов);
}
public bool DeliveryOrder(OrderBindingModel model)
{
return ToNextStatus(model, OrderStatus.Выдан);
}
public bool ToNextStatus(OrderBindingModel model, OrderStatus orderStatus)
{
CheckModel(model, false);
var element = _orderStorage.GetElement(new OrderSearchModel()
{
Id = model.Id
});
if (element == null)
{
throw new ArgumentNullException(nameof(element));
}
model.OrderProduct = element.OrderProduct;
model.DateCreate = element.DateCreate;
model.Status = element.Status;
model.Cost = element.Cost;
if (model.Status != orderStatus - 1)
{
_logger.LogWarning("Status update to " + orderStatus + " operation failed");
return false;
}
model.Status = orderStatus;
if (_orderStorage.Update(model) == null)
{
model.Status--;
_logger.LogWarning("Changing status operation faled");
return false;
}
return true;
}
private void CheckModel(OrderBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (model.Cost <= 0)
{
throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Cost));
}
}
}
}

View File

@ -0,0 +1,115 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.BusinessLogicsContracts;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.StorageContracts;
using ComputerHardwareStoreContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
{
public class ProductLogic : IProductLogic
{
private readonly ILogger _logger;
private readonly IProductStorage _productStorage;
public ProductLogic(ILogger logger, IProductStorage productStorage)
{
_logger = logger;
_productStorage = productStorage;
}
public List<ProductViewModel>? ReadList(ProductSearchModel? model)
{
_logger.LogInformation("ReadList Product. Name:{Name}. Id:{ Id}", model?.Name, model?.Id);
var list = model == null ?
_productStorage.GetFullList() :
_productStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList Product return null list");
return null;
}
_logger.LogInformation("ReadList Product. Count:{Count}", list.Count);
return list;
}
public ProductViewModel? ReadElement(ProductSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement Product. Name:{Name}. Id:{ Id}", model.Name, model.Id);
var element = _productStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement Product element not found");
return null;
}
_logger.LogInformation("ReadElement Product find. Id:{Id}", element.Id);
return element;
}
public bool Create(ProductBindingModel model)
{
CheckModel(model);
if (_productStorage.Insert(model) == null)
{
_logger.LogWarning("Insert Product operation failed");
return false;
}
return true;
}
public bool Update(ProductBindingModel model)
{
CheckModel(model);
if (_productStorage.Update(model) == null)
{
_logger.LogWarning("Update Product Component operation failed");
return false;
}
return true;
}
public bool Delete(ProductBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_productStorage.Delete(model) == null)
{
_logger.LogWarning("Delete Product operation failed");
return false;
}
return true;
}
private void CheckModel(ProductBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentException("Нет названия продукта", nameof(model.Name));
}
if (model.Price <= 0)
{
throw new ArgumentNullException("Цена продукта должна быть больше 0", nameof(model.Price));
}
var element = _productStorage.GetElement(new ProductSearchModel
{
Name = model.Name
});
if (element != null)
{
throw new InvalidOperationException("Продукт с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,105 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.BusinessLogicsContracts;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.StorageContracts;
using ComputerHardwareStoreContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
{
public class PurchaseLogic : IPurchaseLogic
{
private readonly ILogger _logger;
private readonly IPurchaseStorage _purchaseStorage;
public PurchaseLogic(ILogger<PurchaseLogic> logger, IPurchaseStorage purchaseStorage)
{
_logger = logger;
_purchaseStorage = purchaseStorage;
}
public List<PurchaseViewModel>? ReadList(PurchaseSearchModel? model)
{
_logger.LogInformation("ReadList Purchase. Id:{ Id}", model?.Id);
var list = model == null ? _purchaseStorage.GetFullList() :
_purchaseStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList Purchase return null list");
return null;
}
_logger.LogInformation("ReadList Purchase. Count:{Count}", list.Count);
return list;
}
public PurchaseViewModel? ReadElement(PurchaseSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement Purchase. Id:{ Id}", model.Id);
var element = _purchaseStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement Purchase element not found");
return null;
}
_logger.LogInformation("ReadElement Purchase find. Id:{Id}", element.Id);
return element;
}
public bool Create(PurchaseBindingModel model)
{
CheckModel(model);
if (_purchaseStorage.Insert(model) == null)
{
_logger.LogWarning("Insert Purchase operation failed");
return false;
}
return true;
}
public bool Update(PurchaseBindingModel model)
{
CheckModel(model);
if (_purchaseStorage.Update(model) == null)
{
_logger.LogWarning("Update Purchase operation failed");
return false;
}
return true;
}
public bool Delete(PurchaseBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_purchaseStorage.Delete(model) == null)
{
_logger.LogWarning("Delete Purchase operation failed");
return false;
}
return true;
}
private void CheckModel(PurchaseBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.DateCreate))
{
throw new ArgumentNullException("Нет даты создания покупки", nameof(model.Date));
}
if (model.Cost <= 0)
{
throw new ArgumentNullException("Стоимость покупки должна быть больше 0", nameof(model.Cost));
}
}
}
}

View File

@ -0,0 +1,107 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.BusinessLogicsContracts;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.StorageContracts;
using ComputerHardwareStoreContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
{
public class StoreKeeperLogic : IStoreKeeperLogic
{
private readonly ILogger _logger;
private readonly IStoreKeeperStorage _storeKeeperStorage;
public StoreKeeperLogic(ILogger<StoreKeeperLogic> logger, IStoreKeeperStorage storeKeeperStorage)
{
_logger = logger;
_storeKeeperStorage = storeKeeperStorage;
}
public List<StoreKeeperViewModel>? ReadList(StoreKeeperSearchModel? model)
{
_logger.LogInformation("ReadList. Login:{Login}.Id:{Id}", model?.Login, model?.Id);
var list = model == null ? _storeKeeperStorage.GetFullList() : _storeKeeperStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public StoreKeeperViewModel? ReadElement(StoreKeeperSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Login:{Login}.Id:{Id}", model.Login, model.Id);
var element = _storeKeeperStorage.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(StoreKeeperBindingModel model)
{
CheckModel(model);
if (_storeKeeperStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(StoreKeeperBindingModel model)
{
CheckModel(model);
if (_storeKeeperStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(StoreKeeperBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_storeKeeperStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(StoreKeeperBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Login))
{
throw new ArgumentNullException("Нет логина кладовщика", nameof(model.Login));
}
var element = _storeKeeperStorage.GetElement(new StoreKeeperSearchModel
{
Login = model.Login
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Кладовщик с таким логином уже есть");
}
}
}
}

View File

@ -0,0 +1,107 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.BusinessLogicsContracts;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.StorageContracts;
using ComputerHardwareStoreContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace ComputerHardwareStoreBusinessLogic.BusinessLogic
{
public class VendorLogic : IVendorLogic
{
private readonly ILogger _logger;
private readonly IVendorStorage _vendorStorage;
public VendorLogic(ILogger<VendorLogic> logger, IVendorStorage vendorStorage)
{
_logger = logger;
_vendorStorage = vendorStorage;
}
public List<VendorViewModel>? ReadList(VendorSearchModel? model)
{
_logger.LogInformation("ReadList. Login:{Login}.Id:{Id}", model?.Login, model?.Id);
var list = model == null ? _vendorStorage.GetFullList() : _vendorStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public VendorViewModel? ReadElement(VendorSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Login:{Login}.Id:{Id}", model.Login, model.Id);
var element = _vendorStorage.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(VendorBindingModel model)
{
CheckModel(model);
if (_vendorStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(VendorBindingModel model)
{
CheckModel(model);
if (_vendorStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(VendorBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_vendorStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(VendorBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Login))
{
throw new ArgumentNullException("Нет логина работника", nameof(model.Login));
}
var element = _vendorStorage.GetElement(new VendorSearchModel
{
Login = model.Login
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Работник с таким логином уже есть");
}
}
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ComputerHardwareStoreContracts\ComputerHardwareStoreContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,13 @@
using ComputerHardwareStoreDataModels.Models;
namespace ComputerHardwareStoreContracts.BindingModels
{
public class BuildBindingModel : IBuildModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public double Price { get; set; }
public int VendorId { get; set; }
public Dictionary<int, (IComponentModel, int)> BuildComponents { get; set; } = new();
}
}

View File

@ -0,0 +1,12 @@
using ComputerHardwareStoreDataModels.Models;
namespace ComputerHardwareStoreContracts.BindingModels
{
public class CommentBindingModel : ICommentModel
{
public int Id { get; set; }
public DateTime Date { get; set; } = DateTime.Now;
public string Text { get; set; } = string.Empty;
public int BuildId { get; set; }
}
}

View File

@ -0,0 +1,12 @@
using ComputerHardwareStoreDataModels.Models;
namespace ComputerHardwareStoreContracts.BindingModels
{
public class ComponentBindingModel : IComponentModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public double Cost { get; set; }
public int StoreKeeperId { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using ComputerHardwareStoreDataModels.Enums;
using ComputerHardwareStoreDataModels.Models;
namespace ComputerHardwareStoreContracts.BindingModels
{
public class OrderBindingModel : IOrderModel
{
public int Id { get; set; }
public int CannedId { get; set; }
public int Count { get; set; }
public double Cost { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
public DateTime DateCreate { get; set; } = DateTime.Now;
public DateTime? DateImplement { get; set; }
public Dictionary<int, (IProductModel, int)> OrderProduct { get; set; } = new();
}
}

View File

@ -0,0 +1,12 @@
using ComputerHardwareStoreDataModels.Models;
namespace ComputerHardwareStoreContracts.BindingModels
{
public class ProductBindingModel : IProductModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
}
}

View File

@ -0,0 +1,14 @@
using ComputerHardwareStoreDataModels.Models;
namespace ComputerHardwareStoreContracts.BindingModels
{
public class PurchaseBindingModel : IPurchaseModel
{
public int Id { get; set; }
public int VendorId { get; set; }
public double Cost { get; set; }
public DateTime DateCreate { get; set; }
public Dictionary<int, (IBuildModel, int)> PurchaseBuild { get; set; } = new();
public Dictionary<int, (IProductModel, int)> PurchaseProduct { get; set; } = new();
}
}

View File

@ -0,0 +1,12 @@
using ComputerHardwareStoreDataModels.Models;
namespace ComputerHardwareStoreContracts.BindingModels
{
public class StoreKeeperBindingModel : IStoreKeeperModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Login { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,12 @@
using ComputerHardwareStoreDataModels.Models;
namespace ComputerHardwareStoreContracts.BindingModels
{
public class VendorBindingModel : IVendorModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Login { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,15 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.ViewModels;
namespace ComputerHardwareStoreContracts.BusinessLogicsContracts
{
public interface IComponentLogic
{
List<ComponentViewModel>? ReadList(ComponentSearchModel? model);
ComponentViewModel? ReadElement(ComponentSearchModel model);
bool Create(ComponentBindingModel model);
bool Update(ComponentBindingModel model);
bool Delete(ComponentBindingModel model);
}
}

View File

@ -0,0 +1,15 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.ViewModels;
namespace ComputerHardwareStoreContracts.BusinessLogicsContracts
{
public interface IOrderLogic
{
List<OrderViewModel>? ReadList(OrderSearchModel? model);
bool CreateOrder(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model);
bool DeliveryOrder(OrderBindingModel model);
}
}

View File

@ -0,0 +1,15 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.ViewModels;
namespace ComputerHardwareStoreContracts.BusinessLogicsContracts
{
public interface IProductLogic
{
List<ProductViewModel>? ReadList(ProductSearchModel? model);
ProductViewModel? ReadElement(ProductSearchModel model);
bool Create(ProductBindingModel model);
bool Update(ProductBindingModel model);
bool Delete(ProductBindingModel model);
}
}

View File

@ -0,0 +1,15 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.ViewModels;
namespace ComputerHardwareStoreContracts.BusinessLogicsContracts
{
public interface IStoreKeeperLogic
{
List<StoreKeeperViewModel>? ReadList(StoreKeeperSearchModel? model);
StoreKeeperViewModel? ReadElement(StoreKeeperSearchModel model);
bool Create(StoreKeeperBindingModel model);
bool Update(StoreKeeperBindingModel model);
bool Delete(StoreKeeperBindingModel model);
}
}

View File

@ -0,0 +1,15 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.ViewModels;
namespace ComputerHardwareStoreContracts.BusinessLogicsContracts
{
public interface IVendorLogic
{
List<VendorViewModel>? ReadList(VendorSearchModel? model);
VendorViewModel? ReadElement(VendorSearchModel model);
bool Create(VendorBindingModel model);
bool Update(VendorBindingModel model);
bool Delete(VendorBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Remove="BusinessLogicsContracts\IStoreKeeperLogic.cs" />
</ItemGroup>
<ItemGroup>
<None Include="BusinessLogicsContracts\IStoreKeeperLogic.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ComputerHardwareStoreDataModels\ComputerHardwareStoreDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,8 @@
namespace ComputerHardwareStoreContracts.SearchModels
{
public class BuildSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace ComputerHardwareStoreContracts.SearchModels
{
public class CommentSearchModel
{
public int? Id { get; set; }
public DateTime? Date { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace ComputerHardwareStoreContracts.SearchModels
{
public class ComponentSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace ComputerHardwareStoreContracts.SearchModels
{
public class OrderSearchModel
{
public int? Id { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace ComputerHardwareStoreContracts.SearchModels
{
public class ProductSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace ComputerHardwareStoreContracts.SearchModels
{
public class PurchaseSearchModel
{
public int? Id { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace ComputerHardwareStoreContracts.SearchModels
{
public class StoreKeeperSearchModel
{
public int? Id { get; set; }
public string? Login { get; set; }
public string? Password { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace ComputerHardwareStoreContracts.SearchModels
{
public class VendorSearchModel
{
public int? Id { get; set; }
public string? Login { get; set; }
public string? Password { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.ViewModels;
namespace ComputerHardwareStoreContracts.StorageContracts
{
public interface IBuidStorage
{
List<BuildViewModel> GetFullList();
List<BuildViewModel> GetFilteredList(BuildSearchModel model);
BuildViewModel? GetElement(BuildSearchModel model);
BuildViewModel? Insert(BuildBindingModel model);
BuildViewModel? Update(BuildBindingModel model);
BuildViewModel? Delete(BuildBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.ViewModels;
namespace ComputerHardwareStoreContracts.StorageContracts
{
public interface ICommentStorage
{
List<CommentViewModel> GetFullList();
List<CommentViewModel> GetFilteredList(CommentSearchModel model);
CommentViewModel? GetElement(CommentSearchModel model);
CommentViewModel? Insert(CommentBindingModel model);
CommentViewModel? Update(CommentBindingModel model);
CommentViewModel? Delete(CommentBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.ViewModels;
namespace ComputerHardwareStoreContracts.StorageContracts
{
public interface IComponentStorage
{
List<ComponentViewModel> GetFullList();
List<ComponentViewModel> GetFilteredList(ComponentSearchModel model);
ComponentViewModel? GetElement(ComponentSearchModel model);
ComponentViewModel? Insert(ComponentBindingModel model);
ComponentViewModel? Update(ComponentBindingModel model);
ComponentViewModel? Delete(ComponentBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.ViewModels;
namespace ComputerHardwareStoreContracts.StorageContracts
{
public interface IOrderStorage
{
List<OrderViewModel> GetFullList();
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
OrderViewModel? GetElement(OrderSearchModel model);
OrderViewModel? Insert(OrderBindingModel model);
OrderViewModel? Update(OrderBindingModel model);
OrderViewModel? Delete(OrderBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.ViewModels;
namespace ComputerHardwareStoreContracts.StorageContracts
{
public interface IProductStorage
{
List<ProductViewModel> GetFullList();
List<ProductViewModel> GetFilteredList(ProductSearchModel model);
ProductViewModel? GetElement(ProductSearchModel model);
ProductViewModel? Insert(ProductBindingModel model);
ProductViewModel? Update(ProductBindingModel model);
ProductViewModel? Delete(ProductBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.ViewModels;
namespace ComputerHardwareStoreContracts.StorageContracts
{
public interface IPurchaseStorage
{
List<PurchaseViewModel> GetFullList();
List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel model);
PurchaseViewModel? GetElement(PurchaseSearchModel model);
PurchaseViewModel? Insert(PurchaseBindingModel model);
PurchaseViewModel? Update(PurchaseBindingModel model);
PurchaseViewModel? Delete(PurchaseBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.ViewModels;
namespace ComputerHardwareStoreContracts.StorageContracts
{
public interface IStoreKeeperStorage
{
List<StoreKeeperViewModel> GetFullList();
List<StoreKeeperViewModel> GetFilteredList(StoreKeeperSearchModel model);
StoreKeeperViewModel? GetElement(StoreKeeperSearchModel model);
StoreKeeperViewModel? Insert(StoreKeeperBindingModel model);
StoreKeeperViewModel? Update(StoreKeeperBindingModel model);
StoreKeeperViewModel? Delete(StoreKeeperBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using ComputerHardwareStoreContracts.BindingModels;
using ComputerHardwareStoreContracts.SearchModels;
using ComputerHardwareStoreContracts.ViewModels;
namespace ComputerHardwareStoreContracts.StorageContracts
{
public interface IVendorStorage
{
List<VendorViewModel> GetFullList();
List<VendorViewModel> GetFilteredList(VendorSearchModel model);
VendorViewModel? GetElement(VendorSearchModel model);
VendorViewModel? Insert(VendorBindingModel model);
VendorViewModel? Update(VendorBindingModel model);
VendorViewModel? Delete(VendorBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using ComputerHardwareStoreDataModels.Models;
using System.ComponentModel;
namespace ComputerHardwareStoreContracts.ViewModels
{
public class BuildViewModel : IBuildModel
{
public int Id { get; set; }
[DisplayName("Название сборки")]
public string Name { get; } = string.Empty;
[DisplayName("Стоимость")]
public double Price { get; }
public int VendorId { get; }
public Dictionary<int, (IComponentModel, int)> BuildComponents { get; } = new();
}
}

View File

@ -0,0 +1,12 @@
using ComputerHardwareStoreDataModels.Models;
namespace ComputerHardwareStoreContracts.ViewModels
{
public class CommentViewModel : ICommentModel
{
public int Id { get; set; }
public DateTime Date { get; set; }
public string Text { get; set; } = string.Empty;
public int BuildId { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using ComputerHardwareStoreDataModels.Models;
using System.ComponentModel;
namespace ComputerHardwareStoreContracts.ViewModels
{
public class ComponentViewModel : IComponentModel
{
public int Id { get; set; }
[DisplayName("Название компонента")]
public string Name { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Cost { get; set; }
public int StoreKeeperId { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using ComputerHardwareStoreDataModels.Models;
using System.ComponentModel;
namespace ComputerHardwareStoreContracts.ViewModels
{
public class OrderViewModel : IOrderModel
{
public int Id { get; set; }
[DisplayName("Стоимость")]
public double Cost { get; set; }
[DisplayName("Дата создания")]
public DateTime DateCreate { get; set; }
public Dictionary<int, (IProductModel, int)> OrderProduct { get; set; } = new();
}
}

View File

@ -0,0 +1,17 @@
using ComputerHardwareStoreDataModels.Models;
using System.ComponentModel;
namespace ComputerHardwareStoreContracts.ViewModels
{
public class ProductViewModel : IProductModel
{
public int Id { get; set; }
[DisplayName("Название изделия")]
public string Name { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> CannedComponents { get; set; } = new();
public Dictionary<int, (IComponentModel, int)> ProductComponents => throw new NotImplementedException();
}
}

View File

@ -0,0 +1,20 @@
using ComputerHardwareStoreDataModels.Models;
using System.ComponentModel;
namespace ComputerHardwareStoreContracts.ViewModels
{
public class PurchaseViewModel : IPurchaseModel
{
public int Id { get; set; }
[DisplayName("Стоимость")]
public double Cost { get; set; }
[DisplayName("Дата создания")]
public DateTime DateCreate { get; set; }
public int VendorId { get; set; }
[DisplayName("Сумма")]
public double Sum { get; set; }
public Dictionary<int, (IBuildModel, int)> PurchaseBuild { get; set; } = new();
public Dictionary<int, (IProductModel, int)> PurchaseProduct { get; set; } = new();
}
}

View File

@ -0,0 +1,16 @@
using ComputerHardwareStoreDataModels.Models;
using System.ComponentModel;
namespace ComputerHardwareStoreContracts.ViewModels
{
public class StoreKeeperViewModel : IStoreKeeperModel
{
public int Id { get; set; }
[DisplayName("Имя кладовщика")]
public string Name { get; set; } = string.Empty;
[DisplayName("Логин")]
public string Login { get; set; } = string.Empty;
[DisplayName("Пароль")]
public string Password { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,16 @@
using ComputerHardwareStoreDataModels.Models;
using System.ComponentModel;
namespace ComputerHardwareStoreContracts.ViewModels
{
public class VendorViewModel : IVendorModel
{
public int Id { get; set; }
[DisplayName("Имя продавца")]
public string Name { get; set; } = string.Empty;
[DisplayName("Логин")]
public string Login { get; set; } = string.Empty;
[DisplayName("Пароль")]
public string Password { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,11 @@
namespace ComputerHardwareStoreDataModels.Enums
{
public enum OrderStatus
{
Неизвестен = -1,
Принят = 0,
Выполняется = 1,
Готов = 2,
Выдан = 3,
}
}

View File

@ -0,0 +1,7 @@
namespace ComputerHardwareStoreDataModels
{
public interface IId
{
int Id { get; }
}
}

View File

@ -0,0 +1,10 @@
namespace ComputerHardwareStoreDataModels.Models
{
public interface IBuildModel : IId
{
string Name { get; }
double Price { get; }
int VendorId { get; }
public Dictionary<int, (IComponentModel, int)> BuildComponents { get; }
}
}

View File

@ -0,0 +1,9 @@
namespace ComputerHardwareStoreDataModels.Models
{
public interface ICommentModel : IId
{
DateTime Date { get; }
string Text { get; }
int BuildId { get; }
}
}

View File

@ -0,0 +1,9 @@
namespace ComputerHardwareStoreDataModels.Models
{
public interface IComponentModel : IId
{
string Name { get; }
double Cost { get; }
int StoreKeeperId { get; }
}
}

View File

@ -0,0 +1,9 @@
namespace ComputerHardwareStoreDataModels.Models
{
public interface IOrderModel : IId
{
double Cost { get; }
DateTime DateCreate { get; }
public Dictionary<int, (IProductModel, int)> OrderProduct { get; }
}
}

View File

@ -0,0 +1,9 @@
namespace ComputerHardwareStoreDataModels.Models
{
public interface IProductModel : IId
{
string Name { get; }
double Price { get; }
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; }
}
}

View File

@ -0,0 +1,11 @@
namespace ComputerHardwareStoreDataModels.Models
{
public interface IPurchaseModel : IId
{
int VendorId { get; }
double Cost { get; }
DateTime DateCreate { get; }
public Dictionary<int, (IBuildModel, int)> PurchaseBuild { get; }
public Dictionary<int, (IProductModel, int)> PurchaseProduct { get; }
}
}

View File

@ -0,0 +1,9 @@
namespace ComputerHardwareStoreDataModels.Models
{
public interface IStoreKeeperModel : IId
{
string Name { get; }
string Login { get; }
string Password { get; }
}
}

View File

@ -0,0 +1,9 @@
namespace ComputerHardwareStoreDataModels.Models
{
public interface IVendorModel : IId
{
string Name { get; }
string Login { get; }
string Password { get; }
}
}