Добавлены реализации интерфейсов компонентов и суш (роллов) - продуктов короче :) и заменено вездe Product на Sushi
This commit is contained in:
parent
616cbf0ef2
commit
35919d7015
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SushiBarDataModels
|
namespace SushiBarDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IComponentModel
|
public interface IComponentModel
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using System;
|
using SushiBarDataModels.Enums;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SushiBarDataModels
|
namespace SushiBarDataModels
|
||||||
{
|
{
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SushiBarDataModels
|
|
||||||
{
|
|
||||||
public interface IProductModel : IId
|
|
||||||
{
|
|
||||||
string ProductName { get; }
|
|
||||||
double Price { get; }
|
|
||||||
Dictionary<int, (IComponentModel, int)> ProductComponents { get; }
|
|
||||||
}
|
|
||||||
}
|
|
9
ClassLibrary1SushiBarDataModels/ISushiModel.cs
Normal file
9
ClassLibrary1SushiBarDataModels/ISushiModel.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace SushiBarDataModels.Models
|
||||||
|
{
|
||||||
|
public interface ISushiModel : IId
|
||||||
|
{
|
||||||
|
string SushiName { get; }
|
||||||
|
double Price { get; }
|
||||||
|
Dictionary<int, (IComponentModel, int)> SushiComponents { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SushiBarDataModels
|
namespace SushiBarDataModels.Enums
|
||||||
{
|
{
|
||||||
public enum OrderStatus
|
public enum OrderStatus
|
||||||
{
|
{
|
||||||
|
@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarDataModels", "..\Cl
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarContracts", "..\SushiBarContracts\SushiBarContracts.csproj", "{582D62F3-67BC-48E4-BE59-413A8692695B}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarContracts", "..\SushiBarContracts\SushiBarContracts.csproj", "{582D62F3-67BC-48E4-BE59-413A8692695B}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarBusinessLogic", "..\SushiBarBusinessLogic\SushiBarBusinessLogic.csproj", "{5C6C02C5-88B1-4CCE-884D-415E40A94AD8}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -27,6 +29,10 @@ Global
|
|||||||
{582D62F3-67BC-48E4-BE59-413A8692695B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{582D62F3-67BC-48E4-BE59-413A8692695B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{582D62F3-67BC-48E4-BE59-413A8692695B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{582D62F3-67BC-48E4-BE59-413A8692695B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{582D62F3-67BC-48E4-BE59-413A8692695B}.Release|Any CPU.Build.0 = Release|Any CPU
|
{582D62F3-67BC-48E4-BE59-413A8692695B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{5C6C02C5-88B1-4CCE-884D-415E40A94AD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5C6C02C5-88B1-4CCE-884D-415E40A94AD8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5C6C02C5-88B1-4CCE-884D-415E40A94AD8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5C6C02C5-88B1-4CCE-884D-415E40A94AD8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
113
SushiBarBusinessLogic/ComponentLogic.cs
Normal file
113
SushiBarBusinessLogic/ComponentLogic.cs
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
using SushiBarContracts.BindingModel;
|
||||||
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using SushiBarContracts.SearchModel;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using SushiBarContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
|
||||||
|
namespace SushiBarBusinessLogic.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. 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("Компонент с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
112
SushiBarBusinessLogic/Sushi.cs
Normal file
112
SushiBarBusinessLogic/Sushi.cs
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
using SushiBarContracts.BindingModel;
|
||||||
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using SushiBarContracts.SearchModel;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using SushiBarContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace SushiBarBusinessLogic.BusinessLogic
|
||||||
|
{
|
||||||
|
public class Sushi : ISushiLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly ISushiStorage _sushiStorage;
|
||||||
|
|
||||||
|
public Sushi(ILogger<Sushi> logger, ISushiStorage sushiStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_sushiStorage = sushiStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SushiViewModel>? ReadList(SushiSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. SushiName:{SushiName}. Id:{ Id}", model?.SushiName, model?.Id);
|
||||||
|
var list = model == null ? _sushiStorage.GetFullList() : _sushiStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
public SushiViewModel? ReadElement(SushiSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. SushiName:{SushiName}.Id:{ Id}", model.SushiName, model.Id);
|
||||||
|
var element = _sushiStorage.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(SushiBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_sushiStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(SushiBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_sushiStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(SushiBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
if (_sushiStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private void CheckModel(SushiBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.SushiName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия компонента", nameof(model.SushiName));
|
||||||
|
}
|
||||||
|
if (model.Price <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Цена продукта должна быть больше 0", nameof(model.Price));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{ Cost}. Id: { Id}",
|
||||||
|
model.SushiName, model.Price, model.Id);
|
||||||
|
|
||||||
|
var element = _sushiStorage.GetElement(new SushiSearchModel
|
||||||
|
{
|
||||||
|
SushiName = model.SushiName
|
||||||
|
});
|
||||||
|
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
SushiBarBusinessLogic/SushiBarBusinessLogic.csproj
Normal file
17
SushiBarBusinessLogic/SushiBarBusinessLogic.csproj
Normal 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" Version="8.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SushiBarContracts\SushiBarContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
11
SushiBarContracts/BindingModel/ComponentBindingModel.cs
Normal file
11
SushiBarContracts/BindingModel/ComponentBindingModel.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using SushiBarDataModels.Models;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.BindingModel
|
||||||
|
{
|
||||||
|
public class ComponentBindingModel : IComponentModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
|
public double Cost { get; set; }
|
||||||
|
}
|
||||||
|
}
|
22
SushiBarContracts/BindingModel/OrderBindingModel.cs
Normal file
22
SushiBarContracts/BindingModel/OrderBindingModel.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using SushiBarDataModels;
|
||||||
|
using SushiBarDataModels.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.BindingModel
|
||||||
|
{
|
||||||
|
public class OrderBindingModel : IOrderModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int ProductId { 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; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
12
SushiBarContracts/BindingModel/SushiBindingModel.cs
Normal file
12
SushiBarContracts/BindingModel/SushiBindingModel.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using SushiBarDataModels.Models;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.BindingModel
|
||||||
|
{
|
||||||
|
public class SushiBindingModel : ISushiModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string SushiName { get; set; } = string.Empty;
|
||||||
|
public double Price { get; set; }
|
||||||
|
public Dictionary<int, (IComponentModel, int)> SushiComponents { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
15
SushiBarContracts/BusinessLogicsContracts/IComponentLogic.cs
Normal file
15
SushiBarContracts/BusinessLogicsContracts/IComponentLogic.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using SushiBarContracts.BindingModel;
|
||||||
|
using SushiBarContracts.SearchModel;
|
||||||
|
using SushiBarContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.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);
|
||||||
|
}
|
||||||
|
}
|
15
SushiBarContracts/BusinessLogicsContracts/IOrderLogic.cs
Normal file
15
SushiBarContracts/BusinessLogicsContracts/IOrderLogic.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using SushiBarContracts.BindingModel;
|
||||||
|
using SushiBarContracts.SearchModel;
|
||||||
|
using SushiBarContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.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);
|
||||||
|
}
|
||||||
|
}
|
16
SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs
Normal file
16
SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using SushiBarContracts.BindingModel;
|
||||||
|
using SushiBarContracts.SearchModel;
|
||||||
|
using SushiBarContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface ISushiLogic
|
||||||
|
{
|
||||||
|
List<SushiViewModel>? ReadList(SushiSearchModel? model);
|
||||||
|
SushiViewModel? ReadElement(SushiSearchModel model);
|
||||||
|
bool Create(SushiBindingModel model);
|
||||||
|
bool Update(SushiBindingModel model);
|
||||||
|
bool Delete(SushiBindingModel model);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +0,0 @@
|
|||||||
namespace SushiBarContracts
|
|
||||||
{
|
|
||||||
public class Class1
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
9
SushiBarContracts/SearchModel/ComponentSearchModel.cs
Normal file
9
SushiBarContracts/SearchModel/ComponentSearchModel.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
namespace SushiBarContracts.SearchModel
|
||||||
|
{
|
||||||
|
public class ComponentSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? ComponentName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
13
SushiBarContracts/SearchModel/OrderSearchModel.cs
Normal file
13
SushiBarContracts/SearchModel/OrderSearchModel.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.SearchModel
|
||||||
|
{
|
||||||
|
public class OrderSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
8
SushiBarContracts/SearchModel/SushiSearchModel.cs
Normal file
8
SushiBarContracts/SearchModel/SushiSearchModel.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace SushiBarContracts.SearchModel
|
||||||
|
{
|
||||||
|
public class SushiSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? SushiName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
16
SushiBarContracts/StoragesContracts/IComponentStorage.cs
Normal file
16
SushiBarContracts/StoragesContracts/IComponentStorage.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using SushiBarContracts.BindingModel;
|
||||||
|
using SushiBarContracts.SearchModel;
|
||||||
|
using SushiBarContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
16
SushiBarContracts/StoragesContracts/IOrderStorage.cs
Normal file
16
SushiBarContracts/StoragesContracts/IOrderStorage.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using SushiBarContracts.BindingModel;
|
||||||
|
using SushiBarContracts.SearchModel;
|
||||||
|
using SushiBarContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
16
SushiBarContracts/StoragesContracts/ISushiStorage.cs
Normal file
16
SushiBarContracts/StoragesContracts/ISushiStorage.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using SushiBarContracts.BindingModel;
|
||||||
|
using SushiBarContracts.SearchModel;
|
||||||
|
using SushiBarContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface ISushiStorage
|
||||||
|
{
|
||||||
|
List<SushiViewModel> GetFullList();
|
||||||
|
List<SushiViewModel> GetFilteredList(SushiSearchModel model);
|
||||||
|
SushiViewModel? GetElement(SushiSearchModel model);
|
||||||
|
SushiViewModel? Insert(SushiBindingModel model);
|
||||||
|
SushiViewModel? Update(SushiBindingModel model);
|
||||||
|
SushiViewModel? Delete(SushiBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -10,12 +10,4 @@
|
|||||||
<ProjectReference Include="..\ClassLibrary1SushiBarDataModels\SushiBarDataModels.csproj" />
|
<ProjectReference Include="..\ClassLibrary1SushiBarDataModels\SushiBarDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="BindingModel\" />
|
|
||||||
<Folder Include="SearchModel\" />
|
|
||||||
<Folder Include="ViewModel\" />
|
|
||||||
<Folder Include="BusinessLodicsContracts\" />
|
|
||||||
<Folder Include="StoragesContracts\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
18
SushiBarContracts/ViewModels/ComponentViewModel.cs
Normal file
18
SushiBarContracts/ViewModels/ComponentViewModel.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using SushiBarDataModels.Models;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ComponentViewModel : IComponentModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Название компонента")]
|
||||||
|
|
||||||
|
|
||||||
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Цена")]
|
||||||
|
|
||||||
|
|
||||||
|
public double Cost { get; set; }
|
||||||
|
}
|
||||||
|
}
|
38
SushiBarContracts/ViewModels/OrderViewModel.cs
Normal file
38
SushiBarContracts/ViewModels/OrderViewModel.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using SushiBarDataModels.Models;
|
||||||
|
using SushiBarDataModels.Enums;
|
||||||
|
using SushiBarDataModels;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class OrderViewModel : IOrderModel
|
||||||
|
{
|
||||||
|
[DisplayName("Номер")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int ProductId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
[DisplayName("Изделие")]
|
||||||
|
public string ProductName { 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; }
|
||||||
|
}
|
||||||
|
}
|
23
SushiBarContracts/ViewModels/SushiViewModel.cs
Normal file
23
SushiBarContracts/ViewModels/SushiViewModel.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using SushiBarDataModels.Models;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class SushiViewModel : ISushiModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Название изделия")]
|
||||||
|
|
||||||
|
|
||||||
|
public string SushiName { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Цена")]
|
||||||
|
|
||||||
|
|
||||||
|
public double Price { get; set; }
|
||||||
|
public Dictionary<int, (IComponentModel, int)> SushiComponents
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = new();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user