добавление BusinessLogics
This commit is contained in:
parent
d5f7c8ec36
commit
310ce2d3a6
@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.BusinessLogicsContracts;
|
||||
using IceCreamShopContracts.SearchModels;
|
||||
using IceCreamShopContracts.StoragesContracts;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
|
||||
|
||||
namespace IceCreamShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
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. 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("Компонент с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.BusinessLogicsContracts;
|
||||
using IceCreamShopContracts.SearchModels;
|
||||
using IceCreamShopContracts.StoragesContracts;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
|
||||
|
||||
|
||||
namespace IceCreamBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class IceCreamLogic : IIceCreamLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IIceCreamStorage _iceCreamStorage;
|
||||
|
||||
public IceCreamLogic(ILogger<IceCreamLogic> logger, IIceCreamStorage iceCreamStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_iceCreamStorage = iceCreamStorage;
|
||||
}
|
||||
|
||||
public List<IceCreamViewModel>? ReadList (IceCreamSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. IceCreamName:{IceCreamName}. Id:{ Id}", model?.IceCreamName, model?.Id);
|
||||
var list = model == null? _iceCreamStorage.GetFullList() : _iceCreamStorage.GetFilteredList(model);
|
||||
if(list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public IceCreamViewModel? ReadElement (IceCreamSearchModel model)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. IceCreamName:{IceCreamName}. Id:{ Id}", model.IceCreamName, model.Id);
|
||||
var element = _iceCreamStorage.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(IceCreamBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if(_iceCreamStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(IceCreamBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_iceCreamStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(IceCreamBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_iceCreamStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void CheckModel(IceCreamBindingModel model, bool withParams = true)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.IceCreamName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия изделия", nameof(model.IceCreamName));
|
||||
}
|
||||
if (model.Price <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price));
|
||||
}
|
||||
_logger.LogInformation("IceCream. IceCreamName:{IceCreamName}. Price:{Price}. Id: { Id}", model.IceCreamName, model.Price, model.Id);
|
||||
var element = _iceCreamStorage.GetElement(new IceCreamSearchModel { IceCreamName = model.IceCreamName });
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Изделие с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.BusinessLogicsContracts;
|
||||
using IceCreamShopContracts.SearchModels;
|
||||
using IceCreamShopContracts.StoragesContracts;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using AbstractIceCreamShopDataModels.Enums;
|
||||
|
||||
namespace IceCreamBusinessLogic.BusinessLogics
|
||||
{
|
||||
internal class OrderLogic : IOrderLogic
|
||||
{
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
|
||||
public OrderLogic(IOrderStorage orderStorage)
|
||||
{
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
|
||||
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
_orderStorage.Insert(new OrderBindingModel
|
||||
{
|
||||
IceCreamId = model.IceCreamId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = OrderStatus.Принят,
|
||||
DateCreate = DateTime.Now,
|
||||
DateImplement = model.DateImplement
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\IceCreamShopContracts\IceCreamShopContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -7,7 +7,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IceCreamShop", "IceCreamSho
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IceCreamShopDataModels", "IceCreamShopDataModels\IceCreamShopDataModels.csproj", "{998D2482-F931-4FEF-86E9-C21D6757B73A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IceCreamShopContracts", "IceCreamShopContracts\IceCreamShopContracts.csproj", "{80C1052D-54D9-48C0-AFE8-9AD430645FE0}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IceCreamShopContracts", "IceCreamShopContracts\IceCreamShopContracts.csproj", "{80C1052D-54D9-48C0-AFE8-9AD430645FE0}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IceCreamBusinessLogic", "IceCreamBusinessLogic\IceCreamBusinessLogic.csproj", "{E4C64BCD-22DF-43B5-8324-AE64F9237DFF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -27,6 +29,10 @@ Global
|
||||
{80C1052D-54D9-48C0-AFE8-9AD430645FE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{80C1052D-54D9-48C0-AFE8-9AD430645FE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{80C1052D-54D9-48C0-AFE8-9AD430645FE0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E4C64BCD-22DF-43B5-8324-AE64F9237DFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E4C64BCD-22DF-43B5-8324-AE64F9237DFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E4C64BCD-22DF-43B5-8324-AE64F9237DFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E4C64BCD-22DF-43B5-8324-AE64F9237DFF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -8,4 +8,8 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
14
IceCreamShop/IceCreamShopBusinessLogic/1.csproj
Normal file
14
IceCreamShop/IceCreamShopBusinessLogic/1.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\IceCreamShopContracts\IceCreamShopContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,122 @@
|
||||
using AbstractShopContracts.BindingModels;
|
||||
using AbstractShopContracts.BusinessLogicsContracts;
|
||||
using AbstractShopContracts.SearchModels;
|
||||
using AbstractShopContracts.StoragesContracts;
|
||||
using AbstractShopContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
|
||||
namespace IceCreamShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
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. 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("Компонент с таким названием
|
||||
уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,12 +7,12 @@ using AbstractIceCreamShopDataModels.Models;
|
||||
|
||||
namespace IceCreamShopContracts.BindingModels
|
||||
{
|
||||
public class ProductBindingModel : IProductModel
|
||||
public class IceCreamBindingModel : IIceCreamModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
public string IceCreamName { get; set; } = string.Empty;
|
||||
public double Price { get; set; }
|
||||
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
||||
public Dictionary<int, (IComponentModel, int)> IceCreamComponents { get; set; } = new();
|
||||
}
|
||||
|
||||
}
|
@ -11,7 +11,7 @@ namespace IceCreamShopContracts.BindingModels
|
||||
public class OrderBindingModel : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public int IceCreamId { get; set; }
|
||||
public int Count { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
|
@ -0,0 +1,20 @@
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.SearchModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IceCreamShopContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IIceCreamLogic
|
||||
{
|
||||
List<IceCreamViewModel>? ReadList(IceCreamSearchModel? model);
|
||||
IceCreamViewModel? ReadElement(IceCreamSearchModel model);
|
||||
bool Create(IceCreamBindingModel model);
|
||||
bool Update(IceCreamBindingModel model);
|
||||
bool Delete(IceCreamBindingModel model);
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.SearchModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IceCreamShopContracts.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);
|
||||
}
|
||||
}
|
@ -6,6 +6,10 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\IceCreamShopDataModels\IceCreamShopDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
@ -6,9 +6,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace IceCreamShopContracts.SearchModels
|
||||
{
|
||||
public class ProductSearchModel
|
||||
public class IceCreamSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ProductName { get; set; }
|
||||
public string? IceCreamName { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.SearchModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IceCreamShopContracts.StoragesContracts
|
||||
{
|
||||
public interface IIceCreamStorage
|
||||
{
|
||||
List<IceCreamViewModel> GetFullList();
|
||||
List<IceCreamViewModel> GetFilteredList(IceCreamSearchModel model);
|
||||
IceCreamViewModel? GetElement(IceCreamSearchModel model);
|
||||
IceCreamViewModel? Insert(IceCreamBindingModel model);
|
||||
IceCreamViewModel? Update(IceCreamBindingModel model);
|
||||
IceCreamViewModel? Delete(IceCreamBindingModel model);
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.SearchModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IceCreamShopContracts.StoragesContracts
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
@ -8,13 +8,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace IceCreamShopContracts.ViewModels
|
||||
{
|
||||
public class ProductViewModel : IProductModel
|
||||
public class IceCreamViewModel : IIceCreamModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название изделия")]
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
public string IceCreamName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Price { get; set; }
|
||||
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
||||
public Dictionary<int, (IComponentModel, int)> IceCreamComponents { get; set; } = new();
|
||||
}
|
||||
}
|
@ -13,9 +13,9 @@ namespace IceCreamShopContracts.ViewModels
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public int IceCreamId { get; set; }
|
||||
[DisplayName("Изделие")]
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
public string IceCreamName { get; set; } = string.Empty;
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
[DisplayName("Сумма")]
|
||||
|
@ -6,4 +6,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -6,10 +6,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractIceCreamShopDataModels.Models
|
||||
{
|
||||
public interface IProductModel : IId
|
||||
public interface IIceCreamModel : IId
|
||||
{
|
||||
string ProductName { get; }
|
||||
string IceCreamName { get; }
|
||||
double Price { get; }
|
||||
Dictionary<int, (IComponentModel, int)> ProductComponents { get; }
|
||||
Dictionary<int, (IComponentModel, int)> IceCreamComponents { get; }
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ namespace AbstractIceCreamShopDataModels.Models
|
||||
{
|
||||
public interface IOrderModel : IId
|
||||
{
|
||||
int ProductId { get; }
|
||||
int IceCreamId { get; }
|
||||
int Count { get; }
|
||||
double Sum { get; }
|
||||
OrderStatus Status { get; }
|
Loading…
Reference in New Issue
Block a user