Compare commits
No commits in common. "LabWork03" and "main" have entirely different histories.
@ -3,19 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.3.32825.248
|
VisualStudioVersion = 17.3.32825.248
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryDataModels", "FishFactoryDataModels\FishFactoryDataModels.csproj", "{37D4B025-75B2-4B69-9E3A-72897F6DF370}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FishFactoryView", "FishFactoryView\FishFactoryView.csproj", "{B9673528-4858-41F6-B8AF-65030A9A0537}"
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryContracts", "FishFactoryContracts\FishFactoryContracts.csproj", "{BC8980F9-E399-46CB-A8DA-CE512D4563B3}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryBusinessLogic", "FishFactoryBusinessLogic\FishFactoryBusinessLogic.csproj", "{15CC37A7-66F1-4CD8-AC4D-5006B6F2684C}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryListImplement", "FishFactoryListImplement\FishFactoryListImplement.csproj", "{FCFDA778-33D7-42BF-B09C-7C20A2C87672}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryFileImplement", "FishFactoryFileImplement\FishFactoryFileImplement.csproj", "{B842D6FF-1528-4AED-9047-6772D4BEB2EF}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryDatabaseImplement", "FishFactoryDatabaseImplement\FishFactoryDatabaseImplement.csproj", "{F5654037-2B5B-4772-B667-B3A085CA9CE5}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryView", "FishFactoryView\FishFactoryView.csproj", "{5A1CA46A-03B0-4641-B89E-18BBA0A26360}"
|
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -23,34 +11,10 @@ Global
|
|||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{37D4B025-75B2-4B69-9E3A-72897F6DF370}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{B9673528-4858-41F6-B8AF-65030A9A0537}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{37D4B025-75B2-4B69-9E3A-72897F6DF370}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{B9673528-4858-41F6-B8AF-65030A9A0537}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{37D4B025-75B2-4B69-9E3A-72897F6DF370}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{B9673528-4858-41F6-B8AF-65030A9A0537}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{37D4B025-75B2-4B69-9E3A-72897F6DF370}.Release|Any CPU.Build.0 = Release|Any CPU
|
{B9673528-4858-41F6-B8AF-65030A9A0537}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{BC8980F9-E399-46CB-A8DA-CE512D4563B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{BC8980F9-E399-46CB-A8DA-CE512D4563B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{BC8980F9-E399-46CB-A8DA-CE512D4563B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{BC8980F9-E399-46CB-A8DA-CE512D4563B3}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{15CC37A7-66F1-4CD8-AC4D-5006B6F2684C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{15CC37A7-66F1-4CD8-AC4D-5006B6F2684C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{15CC37A7-66F1-4CD8-AC4D-5006B6F2684C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{15CC37A7-66F1-4CD8-AC4D-5006B6F2684C}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{FCFDA778-33D7-42BF-B09C-7C20A2C87672}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{FCFDA778-33D7-42BF-B09C-7C20A2C87672}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{FCFDA778-33D7-42BF-B09C-7C20A2C87672}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{FCFDA778-33D7-42BF-B09C-7C20A2C87672}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{B842D6FF-1528-4AED-9047-6772D4BEB2EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{B842D6FF-1528-4AED-9047-6772D4BEB2EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{B842D6FF-1528-4AED-9047-6772D4BEB2EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{B842D6FF-1528-4AED-9047-6772D4BEB2EF}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{F5654037-2B5B-4772-B667-B3A085CA9CE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{F5654037-2B5B-4772-B667-B3A085CA9CE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{F5654037-2B5B-4772-B667-B3A085CA9CE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{F5654037-2B5B-4772-B667-B3A085CA9CE5}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{5A1CA46A-03B0-4641-B89E-18BBA0A26360}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{5A1CA46A-03B0-4641-B89E-18BBA0A26360}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{5A1CA46A-03B0-4641-B89E-18BBA0A26360}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{5A1CA46A-03B0-4641-B89E-18BBA0A26360}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -1,112 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.StoragesContracts;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace FishFactoryBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class CannedLogic : ICannedLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly ICannedStorage _cannedStorage;
|
|
||||||
public CannedLogic(ILogger<CannedLogic> logger, ICannedStorage cannedStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_cannedStorage = cannedStorage;
|
|
||||||
}
|
|
||||||
public List<CannedViewModel>? ReadList(CannedSearchModel model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. CannedName: {CannedName}. Id: {Id}",
|
|
||||||
model?.CannedName, model?.Id);
|
|
||||||
var list = model == null ? _cannedStorage.GetFullList() :
|
|
||||||
_cannedStorage.GetFilteredList(model);
|
|
||||||
if(list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
public CannedViewModel? ReadElement(CannedSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. CannedName: {CannedName}. Id: {Id}",
|
|
||||||
model?.CannedName, model?.Id);
|
|
||||||
var element = _cannedStorage.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(CannedBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
if(_cannedStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Update(CannedBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
if(_cannedStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Delete(CannedBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
|
||||||
if (_cannedStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private void CheckModel(CannedBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.CannedName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия консервы", nameof(model.CannedName));
|
|
||||||
}
|
|
||||||
if (model.Price <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Цена консервы должна быть больше 0",
|
|
||||||
nameof(model.Price));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Canned. CannedName: {CannedName}. Cost: {Cost}. Id: {Id}",
|
|
||||||
model.CannedName, model.Price, model.Id);
|
|
||||||
var element = _cannedStorage.GetElement(new CannedSearchModel
|
|
||||||
{
|
|
||||||
CannedName = model.CannedName
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Консерва с таким названием уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,112 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.StoragesContracts;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace FishFactoryBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class IngredientLogic : IIngredientLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IIngredientStorage _componentStorage;
|
|
||||||
public IngredientLogic(ILogger<IngredientLogic> logger, IIngredientStorage componentStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_componentStorage = componentStorage;
|
|
||||||
}
|
|
||||||
public List<IngredientViewModel>? ReadList(IngredientSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. IngredientName: {IngredientName}. Id: {Id}",
|
|
||||||
model?.IngredientName, 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 IngredientViewModel? ReadElement(IngredientSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. IngredientName: {IngredientName}. Id: {Id}",
|
|
||||||
model.IngredientName, 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(IngredientBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_componentStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Update(IngredientBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_componentStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Delete(IngredientBindingModel 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(IngredientBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.IngredientName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия ингредиента", nameof(model.IngredientName));
|
|
||||||
}
|
|
||||||
if (model.Cost <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Цена ингредиента должна быть больше 0",
|
|
||||||
nameof(model.Cost));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Ingredient. IngredientName: {IngredientName}. Cost: {Cost}. Id: {Id}",
|
|
||||||
model.IngredientName, model.Cost, model.Id);
|
|
||||||
var element = _componentStorage.GetElement(new IngredientSearchModel
|
|
||||||
{
|
|
||||||
IngredientName = model.IngredientName
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,112 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.StoragesContracts;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryDataModels.Enums;
|
|
||||||
|
|
||||||
namespace FishFactoryBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class OrderLogic : IOrderLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IOrderStorage _orderStorage;
|
|
||||||
|
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_orderStorage = orderStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CreateOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (model.Status != OrderStatus.Неизвестен)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed. Order status incorrect.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
model.Status = OrderStatus.Принят;
|
|
||||||
if (_orderStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
model.Status = OrderStatus.Неизвестен;
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (model.Status + 1 != newStatus)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
model.Status = newStatus;
|
|
||||||
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
|
||||||
if (_orderStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
model.Status--;
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DeliveryOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Выдан);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool FinishOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Готов);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Order. 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (model.CannedId < 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Некорректный идентификатор у консервы", nameof(model.CannedId));
|
|
||||||
}
|
|
||||||
if (model.Count <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Количество консервы в заказе должно быть больше 0", nameof(model.Count));
|
|
||||||
}
|
|
||||||
if (model.Sum <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Order. OrderID:{Id}. Sum:{ Sum}. CannedId: { CannedId}", model.Id, model.Sum, model.CannedId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.3">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FishFactoryContracts\FishFactoryContracts.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,16 +0,0 @@
|
|||||||
using FishFactoryDataModels.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class CannedBindingModel : ICannedModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string CannedName { get; set; } = string.Empty;
|
|
||||||
public double Price { get; set; }
|
|
||||||
public Dictionary<int, (IIngredientModel, int)> CannedIngredients
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
} = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
using FishFactoryDataModels.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class IngredientBindingModel : IIngredientModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string IngredientName { get; set; } = string.Empty;
|
|
||||||
public double Cost { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using FishFactoryDataModels.Enums;
|
|
||||||
using FishFactoryDataModels.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class OrderBindingModel : IOrderModel
|
|
||||||
{
|
|
||||||
public int CannedId { get; set; }
|
|
||||||
public string CannedName { get; set; } = string.Empty;
|
|
||||||
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; }
|
|
||||||
public int Id { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace FishFactoryContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface ICannedLogic
|
|
||||||
{
|
|
||||||
List<CannedViewModel>? ReadList(CannedSearchModel? model);
|
|
||||||
CannedViewModel? ReadElement(CannedSearchModel? model);
|
|
||||||
bool Create(CannedBindingModel? model);
|
|
||||||
bool Update(CannedBindingModel? model);
|
|
||||||
bool Delete(CannedBindingModel? model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace FishFactoryContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IIngredientLogic
|
|
||||||
{
|
|
||||||
List<IngredientViewModel>? ReadList(IngredientSearchModel? model);
|
|
||||||
IngredientViewModel? ReadElement(IngredientSearchModel model);
|
|
||||||
bool Create(IngredientBindingModel model);
|
|
||||||
bool Update(IngredientBindingModel model);
|
|
||||||
bool Delete(IngredientBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace FishFactoryContracts.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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.3">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FishFactoryDataModels\FishFactoryDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,8 +0,0 @@
|
|||||||
namespace FishFactoryContracts.SearchModels
|
|
||||||
{
|
|
||||||
public class CannedSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
public string? CannedName { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
namespace FishFactoryContracts.SearchModels
|
|
||||||
{
|
|
||||||
public class IngredientSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
public string? IngredientName { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
namespace FishFactoryContracts.SearchModels
|
|
||||||
{
|
|
||||||
public class OrderSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace FishFactoryContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface ICannedStorage
|
|
||||||
{
|
|
||||||
List<CannedViewModel> GetFullList();
|
|
||||||
List<CannedViewModel> GetFilteredList(CannedSearchModel model);
|
|
||||||
CannedViewModel? GetElement(CannedSearchModel model);
|
|
||||||
CannedViewModel? Insert(CannedBindingModel model);
|
|
||||||
CannedViewModel? Update(CannedBindingModel model);
|
|
||||||
CannedViewModel? Delete(CannedBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace FishFactoryContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IIngredientStorage
|
|
||||||
{
|
|
||||||
List<IngredientViewModel> GetFullList();
|
|
||||||
List<IngredientViewModel> GetFilteredList(IngredientSearchModel model);
|
|
||||||
IngredientViewModel? GetElement(IngredientSearchModel model);
|
|
||||||
IngredientViewModel? Insert(IngredientBindingModel model);
|
|
||||||
IngredientViewModel? Update(IngredientBindingModel model);
|
|
||||||
IngredientViewModel? Delete(IngredientBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace FishFactoryContracts.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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
using FishFactoryDataModels.Models;
|
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace FishFactoryContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class CannedViewModel : ICannedModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
[DisplayName("Название изделия")]
|
|
||||||
public string CannedName { get; set; } = string.Empty;
|
|
||||||
[DisplayName("Цена")]
|
|
||||||
public double Price { get; set; }
|
|
||||||
public Dictionary<int, (IIngredientModel, int)> CannedIngredients
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
} = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System.ComponentModel;
|
|
||||||
using FishFactoryDataModels.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class IngredientViewModel : IIngredientModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
[DisplayName("Название ингредиента")]
|
|
||||||
public string IngredientName { get; set; } = string.Empty;
|
|
||||||
[DisplayName("Цена")]
|
|
||||||
public double Cost { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
using System.ComponentModel;
|
|
||||||
using FishFactoryDataModels.Enums;
|
|
||||||
using FishFactoryDataModels.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class OrderViewModel : IOrderModel
|
|
||||||
{
|
|
||||||
[DisplayName("Номер")]
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int CannedId { get; set; }
|
|
||||||
[DisplayName("Консерва")]
|
|
||||||
public string CannedName { 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; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
namespace FishFactoryDataModels.Enums
|
|
||||||
{
|
|
||||||
public enum OrderStatus
|
|
||||||
{
|
|
||||||
Неизвестен = -1,
|
|
||||||
Принят = 0,
|
|
||||||
Выполняется = 1,
|
|
||||||
Готов = 2,
|
|
||||||
Выдан = 3
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.3">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,7 +0,0 @@
|
|||||||
namespace FishFactoryDataModels
|
|
||||||
{
|
|
||||||
public interface IId
|
|
||||||
{
|
|
||||||
int Id { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace FishFactoryDataModels.Models
|
|
||||||
{
|
|
||||||
public interface ICannedModel : IId
|
|
||||||
{
|
|
||||||
string CannedName { get; }
|
|
||||||
double Price { get; }
|
|
||||||
Dictionary<int, (IIngredientModel, int)> CannedIngredients { get; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
namespace FishFactoryDataModels.Models
|
|
||||||
{
|
|
||||||
public interface IIngredientModel : IId
|
|
||||||
{
|
|
||||||
string IngredientName { get; }
|
|
||||||
double Cost { get; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using FishFactoryDataModels.Enums;
|
|
||||||
|
|
||||||
namespace FishFactoryDataModels.Models
|
|
||||||
{
|
|
||||||
public interface IOrderModel : IId
|
|
||||||
{
|
|
||||||
int CannedId { get; }
|
|
||||||
int Count { get; }
|
|
||||||
double Sum { get; }
|
|
||||||
OrderStatus Status { get; }
|
|
||||||
DateTime DateCreate { get; }
|
|
||||||
DateTime? DateImplement { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using FishFactoryDatabaseImplement.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement
|
|
||||||
{
|
|
||||||
public class FishFactoryDatabase : DbContext
|
|
||||||
{
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
||||||
{
|
|
||||||
if (optionsBuilder.IsConfigured == false)
|
|
||||||
{
|
|
||||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-OM38GNQ;Initial Catalog=FishFactoryDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
|
||||||
}
|
|
||||||
base.OnConfiguring(optionsBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual DbSet<Ingredient> Ingredients { set; get; }
|
|
||||||
|
|
||||||
public virtual DbSet<Canned> CannedList { set; get; }
|
|
||||||
|
|
||||||
public virtual DbSet<CannedIngredient> CannedIngredients { set; get; }
|
|
||||||
|
|
||||||
public virtual DbSet<Order> Orders { set; get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.3" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.3" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.3">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FishFactoryContracts\FishFactoryContracts.csproj" />
|
|
||||||
<ProjectReference Include="..\FishFactoryDataModels\FishFactoryDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,107 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.StoragesContracts;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryDatabaseImplement.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Implements
|
|
||||||
{
|
|
||||||
public class CannedStorage : ICannedStorage
|
|
||||||
{
|
|
||||||
public List<CannedViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
return context.CannedList
|
|
||||||
.Include(x => x.Ingredients)
|
|
||||||
.ThenInclude(x => x.Ingredient)
|
|
||||||
.ToList()
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CannedViewModel> GetFilteredList(CannedSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.CannedName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
return context.CannedList
|
|
||||||
.Include(x => x.Ingredients)
|
|
||||||
.ThenInclude(x => x.Ingredient)
|
|
||||||
.Where(x => x.CannedName.Contains(model.CannedName))
|
|
||||||
.ToList()
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CannedViewModel? GetElement(CannedSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.CannedName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
return context.CannedList
|
|
||||||
.Include(x => x.Ingredients)
|
|
||||||
.ThenInclude(x => x.Ingredient)
|
|
||||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.CannedName) && x.CannedName == model.CannedName) ||
|
|
||||||
(model.Id.HasValue && x.Id == model.Id))
|
|
||||||
?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CannedViewModel? Insert(CannedBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
var newCanned = Canned.Create(context, model);
|
|
||||||
if (newCanned == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
context.CannedList.Add(newCanned);
|
|
||||||
context.SaveChanges();
|
|
||||||
return newCanned.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CannedViewModel? Update(CannedBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
using var transaction = context.Database.BeginTransaction();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var Canned = context.CannedList.FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
if (Canned == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Canned.Update(model);
|
|
||||||
context.SaveChanges();
|
|
||||||
Canned.UpdateIngredients(context, model);
|
|
||||||
transaction.Commit();
|
|
||||||
return Canned.GetViewModel;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
transaction.Rollback();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CannedViewModel? Delete(CannedBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
var element = context.CannedList
|
|
||||||
.Include(x => x.Ingredients)
|
|
||||||
.Include(x => x.Orders)
|
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
context.CannedList.Remove(element);
|
|
||||||
context.SaveChanges();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.StoragesContracts;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryDatabaseImplement.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Implements
|
|
||||||
{
|
|
||||||
public class IngredientStorage : IIngredientStorage
|
|
||||||
{
|
|
||||||
public List<IngredientViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
return context.Ingredients
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<IngredientViewModel> GetFilteredList(IngredientSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.IngredientName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
return context.Ingredients
|
|
||||||
.Where(x => x.IngredientName.Contains(model.IngredientName))
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IngredientViewModel? GetElement(IngredientSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.IngredientName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
return context.Ingredients
|
|
||||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.IngredientName) && x.IngredientName == model.IngredientName) ||
|
|
||||||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IngredientViewModel? Insert(IngredientBindingModel model)
|
|
||||||
{
|
|
||||||
var newIngredient = Ingredient.Create(model);
|
|
||||||
if (newIngredient == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
context.Ingredients.Add(newIngredient);
|
|
||||||
context.SaveChanges();
|
|
||||||
return newIngredient.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IngredientViewModel? Update(IngredientBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
var ingredient = context.Ingredients.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (ingredient == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
ingredient.Update(model);
|
|
||||||
context.SaveChanges();
|
|
||||||
return ingredient.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IngredientViewModel? Delete(IngredientBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
var element = context.Ingredients.FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
context.Ingredients.Remove(element);
|
|
||||||
context.SaveChanges();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,93 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.StoragesContracts;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryDatabaseImplement.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Implements
|
|
||||||
{
|
|
||||||
public class OrderStorage : IOrderStorage
|
|
||||||
{
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
var element = context.Orders
|
|
||||||
.Include(x => x.Canned)
|
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
context.Orders.Remove(element);
|
|
||||||
context.SaveChanges();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
return context.Orders
|
|
||||||
.Include(x => x.Canned)
|
|
||||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
|
||||||
?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
return context.Orders
|
|
||||||
.Include(x => x.Canned)
|
|
||||||
.Where(x => x.Id == model.Id)
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
public List<OrderViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
return context.Orders
|
|
||||||
.Include(x => x.Canned)
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
var newOrder = Order.Create(model);
|
|
||||||
if (newOrder == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
context.Orders.Add(newOrder);
|
|
||||||
context.SaveChanges();
|
|
||||||
return context.Orders
|
|
||||||
.Include(x => x.Canned)
|
|
||||||
.FirstOrDefault(x => x.Id == newOrder.Id)
|
|
||||||
?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new FishFactoryDatabase();
|
|
||||||
var order = context.Orders
|
|
||||||
.Include(x => x.Canned)
|
|
||||||
.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (order == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
order.Update(model);
|
|
||||||
context.SaveChanges();
|
|
||||||
return order.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,171 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using FishFactoryDatabaseImplement;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(FishFactoryDatabase))]
|
|
||||||
[Migration("20230315130506_InitialCreate")]
|
|
||||||
partial class InitialCreate
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "7.0.3")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("CannedName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<double>("Price")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("CannedList");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedIngredient", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("CannedId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("IngredientId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("CannedId");
|
|
||||||
|
|
||||||
b.HasIndex("IngredientId");
|
|
||||||
|
|
||||||
b.ToTable("CannedIngredients");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Ingredient", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<double>("Cost")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.Property<string>("IngredientName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Ingredients");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("CannedId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("DateImplement")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<double>("Sum")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("CannedId");
|
|
||||||
|
|
||||||
b.ToTable("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedIngredient", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
|
|
||||||
.WithMany("Ingredients")
|
|
||||||
.HasForeignKey("CannedId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("FishFactoryDatabaseImplement.Models.Ingredient", "Ingredient")
|
|
||||||
.WithMany("SushiIngredients")
|
|
||||||
.HasForeignKey("IngredientId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Canned");
|
|
||||||
|
|
||||||
b.Navigation("Ingredient");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("CannedId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Canned");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Ingredients");
|
|
||||||
|
|
||||||
b.Navigation("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Ingredient", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("SushiIngredients");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,125 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class InitialCreate : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "CannedList",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
CannedName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Price = table.Column<double>(type: "float", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_CannedList", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Ingredients",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
IngredientName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Cost = table.Column<double>(type: "float", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Ingredients", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Orders",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
CannedId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Count = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Sum = table.Column<double>(type: "float", nullable: false),
|
|
||||||
Status = table.Column<int>(type: "int", nullable: false),
|
|
||||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
||||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Orders_CannedList_CannedId",
|
|
||||||
column: x => x.CannedId,
|
|
||||||
principalTable: "CannedList",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "CannedIngredients",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
CannedId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
IngredientId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Count = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_CannedIngredients", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_CannedIngredients_CannedList_CannedId",
|
|
||||||
column: x => x.CannedId,
|
|
||||||
principalTable: "CannedList",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_CannedIngredients_Ingredients_IngredientId",
|
|
||||||
column: x => x.IngredientId,
|
|
||||||
principalTable: "Ingredients",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_CannedIngredients_CannedId",
|
|
||||||
table: "CannedIngredients",
|
|
||||||
column: "CannedId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_CannedIngredients_IngredientId",
|
|
||||||
table: "CannedIngredients",
|
|
||||||
column: "IngredientId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_CannedId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "CannedId");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "CannedIngredients");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Orders");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Ingredients");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "CannedList");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,168 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using FishFactoryDatabaseImplement;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(FishFactoryDatabase))]
|
|
||||||
partial class FishFactoryDatabaseModelSnapshot : ModelSnapshot
|
|
||||||
{
|
|
||||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "7.0.3")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("CannedName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<double>("Price")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("CannedList");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedIngredient", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("CannedId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("IngredientId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("CannedId");
|
|
||||||
|
|
||||||
b.HasIndex("IngredientId");
|
|
||||||
|
|
||||||
b.ToTable("CannedIngredients");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Ingredient", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<double>("Cost")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.Property<string>("IngredientName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Ingredients");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("CannedId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("DateImplement")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<double>("Sum")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("CannedId");
|
|
||||||
|
|
||||||
b.ToTable("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedIngredient", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
|
|
||||||
.WithMany("Ingredients")
|
|
||||||
.HasForeignKey("CannedId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("FishFactoryDatabaseImplement.Models.Ingredient", "Ingredient")
|
|
||||||
.WithMany("SushiIngredients")
|
|
||||||
.HasForeignKey("IngredientId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Canned");
|
|
||||||
|
|
||||||
b.Navigation("Ingredient");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("CannedId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Canned");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Ingredients");
|
|
||||||
|
|
||||||
b.Navigation("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Ingredient", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("SushiIngredients");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,99 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryDataModels.Models;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class Canned : ICannedModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string CannedName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public double Price { get; set; }
|
|
||||||
|
|
||||||
private Dictionary<int, (IIngredientModel, int)>? _cannedIngredients = null;
|
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public Dictionary<int, (IIngredientModel, int)> CannedIngredients
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_cannedIngredients == null)
|
|
||||||
{
|
|
||||||
_cannedIngredients = Ingredients
|
|
||||||
.ToDictionary(recPC => recPC.IngredientId, recPC => (recPC.Ingredient as IIngredientModel, recPC.Count));
|
|
||||||
}
|
|
||||||
return _cannedIngredients;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[ForeignKey("CannedId")]
|
|
||||||
public virtual List<CannedIngredient> Ingredients { get; set; } = new();
|
|
||||||
|
|
||||||
[ForeignKey("CannedId")]
|
|
||||||
public virtual List<Order> Orders { get; set; } = new();
|
|
||||||
|
|
||||||
public static Canned Create(FishFactoryDatabase context, CannedBindingModel model)
|
|
||||||
{
|
|
||||||
return new Canned()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
CannedName = model.CannedName,
|
|
||||||
Price = model.Price,
|
|
||||||
Ingredients = model.CannedIngredients.Select(x => new CannedIngredient
|
|
||||||
{
|
|
||||||
Ingredient = context.Ingredients.First(y => y.Id == x.Key),
|
|
||||||
Count = x.Value.Item2
|
|
||||||
}).ToList()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(CannedBindingModel model)
|
|
||||||
{
|
|
||||||
CannedName = model.CannedName;
|
|
||||||
Price = model.Price;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CannedViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
CannedName = CannedName,
|
|
||||||
Price = Price,
|
|
||||||
CannedIngredients = CannedIngredients
|
|
||||||
};
|
|
||||||
|
|
||||||
public void UpdateIngredients(FishFactoryDatabase context, CannedBindingModel model)
|
|
||||||
{
|
|
||||||
var cannedIngredients = context.CannedIngredients.Where(rec => rec.CannedId == model.Id).ToList();
|
|
||||||
if (cannedIngredients != null && cannedIngredients.Count > 0)
|
|
||||||
{ // удалили те, которых нет в модели
|
|
||||||
context.CannedIngredients.RemoveRange(cannedIngredients.Where(rec => !model.CannedIngredients.ContainsKey(rec.IngredientId)));
|
|
||||||
context.SaveChanges();
|
|
||||||
// обновили количество у существующих записей
|
|
||||||
foreach (var updateIngredient in cannedIngredients)
|
|
||||||
{
|
|
||||||
updateIngredient.Count = model.CannedIngredients[updateIngredient.IngredientId].Item2;
|
|
||||||
model.CannedIngredients.Remove(updateIngredient.IngredientId);
|
|
||||||
}
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
var canned = context.CannedList.First(x => x.Id == Id);
|
|
||||||
foreach (var cd in model.CannedIngredients)
|
|
||||||
{
|
|
||||||
context.CannedIngredients.Add(new CannedIngredient
|
|
||||||
{
|
|
||||||
Canned = canned,
|
|
||||||
Ingredient = context.Ingredients.First(x => x.Id == cd.Key),
|
|
||||||
Count = cd.Value.Item2
|
|
||||||
});
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
_cannedIngredients = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class CannedIngredient
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int CannedId { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int IngredientId { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int Count { get; set; }
|
|
||||||
|
|
||||||
public virtual Ingredient Ingredient { get; set; } = new();
|
|
||||||
|
|
||||||
public virtual Canned Canned { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryDataModels.Models;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class Ingredient : IIngredientModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string IngredientName { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public double Cost { get; set; }
|
|
||||||
|
|
||||||
[ForeignKey("IngredientId")]
|
|
||||||
public virtual List<CannedIngredient> SushiIngredients { get; set; } = new();
|
|
||||||
|
|
||||||
public static Ingredient? Create(IngredientBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Ingredient()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
IngredientName = model.IngredientName,
|
|
||||||
Cost = model.Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Ingredient Create(IngredientViewModel model)
|
|
||||||
{
|
|
||||||
return new Ingredient
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
IngredientName = model.IngredientName,
|
|
||||||
Cost = model.Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(IngredientBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
IngredientName = model.IngredientName;
|
|
||||||
Cost = model.Cost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IngredientViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
IngredientName = IngredientName,
|
|
||||||
Cost = Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryDataModels.Models;
|
|
||||||
using FishFactoryDataModels.Enums;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class Order : IOrderModel
|
|
||||||
{
|
|
||||||
[Required]
|
|
||||||
public int CannedId { get; set; }
|
|
||||||
[Required]
|
|
||||||
public int Count { get; set; }
|
|
||||||
[Required]
|
|
||||||
public double Sum { get; set; }
|
|
||||||
[Required]
|
|
||||||
public OrderStatus Status { get; set; }
|
|
||||||
[Required]
|
|
||||||
public DateTime DateCreate { get; set; }
|
|
||||||
public DateTime? DateImplement { get; set; }
|
|
||||||
public int Id { get; set; }
|
|
||||||
public Canned Canned { get; set; }
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Order()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
CannedId = model.CannedId,
|
|
||||||
Count = model.Count,
|
|
||||||
Sum = model.Sum,
|
|
||||||
Status = model.Status,
|
|
||||||
DateCreate = model.DateCreate,
|
|
||||||
DateImplement = model.DateImplement,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Status = model.Status;
|
|
||||||
DateImplement = model.DateImplement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
CannedId = CannedId,
|
|
||||||
Count = Count,
|
|
||||||
Sum = Sum,
|
|
||||||
DateCreate = DateCreate,
|
|
||||||
DateImplement = DateImplement,
|
|
||||||
Id = Id,
|
|
||||||
Status = Status,
|
|
||||||
CannedName = Canned.CannedName,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
using FishFactoryFileImplement.Models;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace FishFactoryFileImplement
|
|
||||||
{
|
|
||||||
public class DataFileSingleton
|
|
||||||
{
|
|
||||||
private static DataFileSingleton? instance;
|
|
||||||
private readonly string IngredientFileName = "Ingredient.xml";
|
|
||||||
private readonly string OrderFileName = "Order.xml";
|
|
||||||
private readonly string CannedFileName = "Canned.xml";
|
|
||||||
public List<Ingredient> Ingredients { get; private set; }
|
|
||||||
public List<Order> Orders { get; private set; }
|
|
||||||
public List<Canned> ListCanned { get; private set; }
|
|
||||||
public static DataFileSingleton GetInstance()
|
|
||||||
{
|
|
||||||
if (instance == null)
|
|
||||||
{
|
|
||||||
instance = new DataFileSingleton();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
public void SaveIngredients() => SaveData(Ingredients, IngredientFileName,
|
|
||||||
"Ingredients", x => x.GetXElement);
|
|
||||||
|
|
||||||
public void SaveListCanned() => SaveData(ListCanned, CannedFileName,
|
|
||||||
"ListCanned", x => x.GetXElement);
|
|
||||||
|
|
||||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
|
||||||
|
|
||||||
private DataFileSingleton()
|
|
||||||
{
|
|
||||||
Ingredients = LoadData(IngredientFileName, "Ingredient", x => Ingredient.Create(x)!)!;
|
|
||||||
ListCanned = LoadData(CannedFileName, "Canned", x => Canned.Create(x)!)!;
|
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
|
||||||
Func<XElement, T> selectFunction)
|
|
||||||
{
|
|
||||||
if (File.Exists(filename))
|
|
||||||
{
|
|
||||||
return
|
|
||||||
XDocument.Load(filename)?.Root?.Elements(xmlNodeName)?.Select(selectFunction)?.ToList();
|
|
||||||
}
|
|
||||||
return new List<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SaveData<T>(List<T> data, string filename, string
|
|
||||||
xmlNodeName, Func<T, XElement> selectFunction)
|
|
||||||
{
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.3">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FishFactoryContracts\FishFactoryContracts.csproj" />
|
|
||||||
<ProjectReference Include="..\FishFactoryDataModels\FishFactoryDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,80 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.StoragesContracts;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryFileImplement.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryFileImplement.Implements
|
|
||||||
{
|
|
||||||
public class CannedStorage : ICannedStorage
|
|
||||||
{
|
|
||||||
private readonly DataFileSingleton source;
|
|
||||||
public CannedStorage()
|
|
||||||
{
|
|
||||||
source = DataFileSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CannedViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
return source.ListCanned.Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CannedViewModel> GetFilteredList(CannedSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.CannedName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
return source.ListCanned.Where(x =>
|
|
||||||
x.CannedName.Contains(model.CannedName)).Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CannedViewModel? GetElement(CannedSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.CannedName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return source.ListCanned.FirstOrDefault(x =>
|
|
||||||
(!string.IsNullOrEmpty(model.CannedName) && x.CannedName ==
|
|
||||||
model.CannedName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CannedViewModel? Insert(CannedBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = source.ListCanned.Count > 0 ? source.ListCanned.Max(x => x.Id) + 1 : 1;
|
|
||||||
var newCanned = Canned.Create(model);
|
|
||||||
if (newCanned == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
source.ListCanned.Add(newCanned);
|
|
||||||
source.SaveListCanned();
|
|
||||||
return newCanned.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CannedViewModel? Update(CannedBindingModel model)
|
|
||||||
{
|
|
||||||
var canned = source.ListCanned.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (canned == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
canned.Update(model);
|
|
||||||
source.SaveListCanned();
|
|
||||||
return canned.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CannedViewModel? Delete(CannedBindingModel model)
|
|
||||||
{
|
|
||||||
var element = source.ListCanned.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
source.ListCanned.Remove(element);
|
|
||||||
source.SaveListCanned();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.StoragesContracts;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryFileImplement.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryFileImplement.Implements
|
|
||||||
{
|
|
||||||
public class IngredientStorage : IIngredientStorage
|
|
||||||
{
|
|
||||||
private readonly DataFileSingleton source;
|
|
||||||
public IngredientStorage()
|
|
||||||
{
|
|
||||||
source = DataFileSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
public List<IngredientViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
return source.Ingredients.Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
public List<IngredientViewModel> GetFilteredList(IngredientSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.IngredientName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
return source.Ingredients.Where(x =>
|
|
||||||
x.IngredientName.Contains(model.IngredientName)).Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
public IngredientViewModel? GetElement(IngredientSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.IngredientName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return source.Ingredients.FirstOrDefault(x =>
|
|
||||||
(!string.IsNullOrEmpty(model.IngredientName) && x.IngredientName ==
|
|
||||||
model.IngredientName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
|
||||||
}
|
|
||||||
public IngredientViewModel? Insert(IngredientBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = source.Ingredients.Count > 0 ? source.Ingredients.Max(x => x.Id) + 1 : 1;
|
|
||||||
var newIngredient = Ingredient.Create(model);
|
|
||||||
if (newIngredient == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
source.Ingredients.Add(newIngredient);
|
|
||||||
source.SaveIngredients();
|
|
||||||
return newIngredient.GetViewModel;
|
|
||||||
}
|
|
||||||
public IngredientViewModel? Update(IngredientBindingModel model)
|
|
||||||
{
|
|
||||||
var ingredient = source.Ingredients.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (ingredient == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
ingredient.Update(model);
|
|
||||||
source.SaveIngredients();
|
|
||||||
return ingredient.GetViewModel;
|
|
||||||
}
|
|
||||||
public IngredientViewModel? Delete(IngredientBindingModel model)
|
|
||||||
{
|
|
||||||
var element = source.Ingredients.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
source.Ingredients.Remove(element);
|
|
||||||
source.SaveIngredients();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.StoragesContracts;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryFileImplement.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryFileImplement.Implements
|
|
||||||
{
|
|
||||||
public class OrderStorage :IOrderStorage
|
|
||||||
{
|
|
||||||
private readonly DataFileSingleton source;
|
|
||||||
public OrderStorage()
|
|
||||||
{
|
|
||||||
source = DataFileSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
return source.Orders.Select(x => GetViewModel(x)).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
return source.Orders.Where(x => x.Id.Equals(model.Id)).Select(x => GetViewModel(x)).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return source.Orders.FirstOrDefault(x =>
|
|
||||||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
|
||||||
}
|
|
||||||
private OrderViewModel GetViewModel(Order order)
|
|
||||||
{
|
|
||||||
var viewModel = order.GetViewModel;
|
|
||||||
foreach (var canned in source.ListCanned)
|
|
||||||
{
|
|
||||||
if (canned.Id == order.CannedId)
|
|
||||||
{
|
|
||||||
viewModel.CannedName = canned.CannedName;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return viewModel;
|
|
||||||
}
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = source.Orders.Count > 0 ? source.Orders.Max(x => x.Id) + 1 : 1;
|
|
||||||
var newOrder = Order.Create(model);
|
|
||||||
if (newOrder == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
source.Orders.Add(newOrder);
|
|
||||||
source.SaveOrders();
|
|
||||||
return GetViewModel(newOrder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (order == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
order.Update(model);
|
|
||||||
source.SaveOrders();
|
|
||||||
return GetViewModel(order);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
var element = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
source.Orders.Remove(element);
|
|
||||||
source.SaveOrders();
|
|
||||||
return GetViewModel(element);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryDataModels.Models;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace FishFactoryFileImplement.Models
|
|
||||||
{
|
|
||||||
public class Canned : ICannedModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string CannedName { get; private set; } = string.Empty;
|
|
||||||
public double Price { get; private set; }
|
|
||||||
public Dictionary<int, int> Ingredients { get; private set; } = new();
|
|
||||||
private Dictionary<int, (IIngredientModel, int)>? _productIngredients = null;
|
|
||||||
public Dictionary<int, (IIngredientModel, int)> CannedIngredients
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if(_productIngredients == null)
|
|
||||||
{
|
|
||||||
var source = DataFileSingleton.GetInstance();
|
|
||||||
_productIngredients = Ingredients.ToDictionary(x => x.Key, y => ((source.Ingredients.FirstOrDefault(z => z.Id == y.Key) as IIngredientModel)!, y.Value));
|
|
||||||
}
|
|
||||||
return _productIngredients;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Canned? Create(CannedBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Canned()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
CannedName = model.CannedName,
|
|
||||||
Price = model.Price,
|
|
||||||
Ingredients = model.CannedIngredients.ToDictionary(x => x.Key, x => x.Value.Item2)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Canned? Create(XElement element)
|
|
||||||
{
|
|
||||||
if(element == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Canned()
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
||||||
CannedName = element.Element("CannedName")!.Value,
|
|
||||||
Price = Convert.ToDouble(element.Element("Price")!.Value),
|
|
||||||
Ingredients = element.Element("CannedIngredients")!.Elements("CannedIngredient").ToDictionary(x =>
|
|
||||||
Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(CannedBindingModel model)
|
|
||||||
{
|
|
||||||
if(model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CannedName = model.CannedName;
|
|
||||||
Price = model.Price;
|
|
||||||
Ingredients = model.CannedIngredients.ToDictionary(x => x.Key, x => x.Value.Item2);
|
|
||||||
_productIngredients = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CannedViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
CannedName = CannedName,
|
|
||||||
Price = Price,
|
|
||||||
CannedIngredients = CannedIngredients,
|
|
||||||
};
|
|
||||||
|
|
||||||
public XElement GetXElement => new("Canned",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("CannedName", CannedName),
|
|
||||||
new XElement("Price", Price.ToString()),
|
|
||||||
new XElement("CannedIngredients", Ingredients.Select(x => new XElement("CannedIngredient",
|
|
||||||
new XElement("Key", x.Key), new XElement("Value", x.Value))).ToArray()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryDataModels.Models;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace FishFactoryFileImplement.Models
|
|
||||||
{
|
|
||||||
public class Ingredient : IIngredientModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string IngredientName { get; private set; } = string.Empty;
|
|
||||||
public double Cost { get; set; }
|
|
||||||
public static Ingredient? Create(IngredientBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Ingredient()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
IngredientName = model.IngredientName,
|
|
||||||
Cost = model.Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public static Ingredient? Create(XElement element)
|
|
||||||
{
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Ingredient()
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
||||||
IngredientName = element.Element("IngredientName")!.Value,
|
|
||||||
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(IngredientBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
IngredientName = model.IngredientName;
|
|
||||||
Cost = model.Cost;
|
|
||||||
}
|
|
||||||
public IngredientViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
IngredientName = IngredientName,
|
|
||||||
Cost = Cost
|
|
||||||
};
|
|
||||||
public XElement GetXElement => new("Ingredient",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("IngredientName", IngredientName),
|
|
||||||
new XElement("Cost", Cost.ToString()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryDataModels.Models;
|
|
||||||
using FishFactoryDataModels.Enums;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace FishFactoryFileImplement.Models
|
|
||||||
{
|
|
||||||
public class Order : IOrderModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public int CannedId { get; private set; }
|
|
||||||
public int Count { get; private set; }
|
|
||||||
public double Sum { get; private set; }
|
|
||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
|
||||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
|
||||||
public DateTime? DateImplement { get; private set; }
|
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Order()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
CannedId = model.CannedId,
|
|
||||||
Count = model.Count,
|
|
||||||
Sum = model.Sum,
|
|
||||||
Status = model.Status,
|
|
||||||
DateCreate = model.DateCreate,
|
|
||||||
DateImplement = model.DateImplement,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Order? Create(XElement element)
|
|
||||||
{
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Order()
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
||||||
CannedId = Convert.ToInt32(element.Element("CannedId")!.Value),
|
|
||||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
|
||||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
|
||||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
|
||||||
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
|
||||||
DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null : Convert.ToDateTime(element.Element("DateImplement")!.Value)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Status = model.Status;
|
|
||||||
DateImplement = model.DateImplement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
CannedId = CannedId,
|
|
||||||
Count = Count,
|
|
||||||
Sum = Sum,
|
|
||||||
DateCreate = DateCreate,
|
|
||||||
DateImplement = DateImplement,
|
|
||||||
Id = Id,
|
|
||||||
Status = Status,
|
|
||||||
};
|
|
||||||
|
|
||||||
public XElement GetXElement => new("Order",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("CannedId", CannedId),
|
|
||||||
new XElement("Count", Count.ToString()),
|
|
||||||
new XElement("Sum", Sum.ToString()),
|
|
||||||
new XElement("Status", Status.ToString()),
|
|
||||||
new XElement("DateCreate", DateCreate.ToString()),
|
|
||||||
new XElement("DateImplement", DateImplement.ToString()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
using FishFactoryListImplement.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryListImplement
|
|
||||||
{
|
|
||||||
public class DataListSingleton
|
|
||||||
{
|
|
||||||
private static DataListSingleton? _instance;
|
|
||||||
public List<Ingredient> Ingredients { get; set; }
|
|
||||||
public List<Order> Orders { get; set; }
|
|
||||||
public List<Canned> ListCanned { get; set; }
|
|
||||||
|
|
||||||
private DataListSingleton()
|
|
||||||
{
|
|
||||||
Ingredients = new List<Ingredient>();
|
|
||||||
Orders = new List<Order>();
|
|
||||||
ListCanned = new List<Canned>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DataListSingleton GetInstance()
|
|
||||||
{
|
|
||||||
if (_instance == null)
|
|
||||||
{
|
|
||||||
_instance = new DataListSingleton();
|
|
||||||
}
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.3">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FishFactoryContracts\FishFactoryContracts.csproj" />
|
|
||||||
<ProjectReference Include="..\FishFactoryDataModels\FishFactoryDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,108 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.StoragesContracts;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryListImplement.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryListImplement.Implements
|
|
||||||
{
|
|
||||||
public class CannedStorage : ICannedStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
public CannedStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CannedViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<CannedViewModel>();
|
|
||||||
foreach(var canned in _source.ListCanned)
|
|
||||||
{
|
|
||||||
result.Add(canned.GetViewModel);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CannedViewModel> GetFilteredList(CannedSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<CannedViewModel>();
|
|
||||||
if (string.IsNullOrEmpty(model.CannedName))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
foreach (var canned in _source.ListCanned)
|
|
||||||
{
|
|
||||||
if (canned.CannedName.Contains(model.CannedName))
|
|
||||||
{
|
|
||||||
result.Add(canned.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CannedViewModel? GetElement(CannedSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.CannedName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var canned in _source.ListCanned)
|
|
||||||
{
|
|
||||||
if ((!string.IsNullOrEmpty(model.CannedName) &&
|
|
||||||
canned.CannedName == model.CannedName) ||
|
|
||||||
(model.Id.HasValue && canned.Id == model.Id))
|
|
||||||
{
|
|
||||||
return canned.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CannedViewModel? Insert(CannedBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
foreach (var canned in _source.ListCanned)
|
|
||||||
{
|
|
||||||
if (model.Id <= canned.Id)
|
|
||||||
{
|
|
||||||
model.Id = canned.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var newSushi = Canned.Create(model);
|
|
||||||
if (newSushi == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_source.ListCanned.Add(newSushi);
|
|
||||||
return newSushi.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CannedViewModel? Update(CannedBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var canned in _source.ListCanned)
|
|
||||||
{
|
|
||||||
if (canned.Id == model.Id)
|
|
||||||
{
|
|
||||||
canned.Update(model);
|
|
||||||
return canned.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CannedViewModel? Delete(CannedBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.ListCanned.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.ListCanned[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.ListCanned[i];
|
|
||||||
_source.ListCanned.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,108 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.StoragesContracts;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryListImplement.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryListImplement.Implements
|
|
||||||
{
|
|
||||||
public class IngredientStorage : IIngredientStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
public IngredientStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<IngredientViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<IngredientViewModel>();
|
|
||||||
foreach (var component in _source.Ingredients)
|
|
||||||
{
|
|
||||||
result.Add(component.GetViewModel);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<IngredientViewModel> GetFilteredList(IngredientSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<IngredientViewModel>();
|
|
||||||
if (string.IsNullOrEmpty(model.IngredientName))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
foreach (var component in _source.Ingredients)
|
|
||||||
{
|
|
||||||
if (component.IngredientName.Contains(model.IngredientName))
|
|
||||||
{
|
|
||||||
result.Add(component.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IngredientViewModel? GetElement(IngredientSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.IngredientName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var component in _source.Ingredients)
|
|
||||||
{
|
|
||||||
if ((!string.IsNullOrEmpty(model.IngredientName) &&
|
|
||||||
component.IngredientName == model.IngredientName) ||
|
|
||||||
(model.Id.HasValue && component.Id == model.Id))
|
|
||||||
{
|
|
||||||
return component.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IngredientViewModel? Insert(IngredientBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
foreach (var component in _source.Ingredients)
|
|
||||||
{
|
|
||||||
if (model.Id <= component.Id)
|
|
||||||
{
|
|
||||||
model.Id = component.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var newIngredient = Ingredient.Create(model);
|
|
||||||
if (newIngredient == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_source.Ingredients.Add(newIngredient);
|
|
||||||
return newIngredient.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IngredientViewModel? Update(IngredientBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var component in _source.Ingredients)
|
|
||||||
{
|
|
||||||
if (component.Id == model.Id)
|
|
||||||
{
|
|
||||||
component.Update(model);
|
|
||||||
return component.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IngredientViewModel? Delete(IngredientBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Ingredients.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Ingredients[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Ingredients[i];
|
|
||||||
_source.Ingredients.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,105 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryContracts.StoragesContracts;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryListImplement.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryListImplement.Implements
|
|
||||||
{
|
|
||||||
public class OrderStorage : IOrderStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
public OrderStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
public List<OrderViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<OrderViewModel>();
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
result.Add(order.GetViewModel);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<OrderViewModel>();
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (order.Id == model.Id)
|
|
||||||
{
|
|
||||||
result.Add(order.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (model.Id.HasValue && order.Id == model.Id)
|
|
||||||
{
|
|
||||||
return order.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (model.Id <= order.Id)
|
|
||||||
{
|
|
||||||
model.Id = order.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var newOrder = Order.Create(model);
|
|
||||||
if (newOrder == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_source.Orders.Add(newOrder);
|
|
||||||
return newOrder.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (order.Id == model.Id)
|
|
||||||
{
|
|
||||||
order.Update(model);
|
|
||||||
return order.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Orders.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Orders[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Orders[i];
|
|
||||||
_source.Orders.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryDataModels.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryListImplement.Models
|
|
||||||
{
|
|
||||||
public class Canned : ICannedModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string CannedName { get; private set; } = string.Empty;
|
|
||||||
public double Price { get; private set; }
|
|
||||||
public Dictionary<int, (IIngredientModel, int)> CannedIngredients
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
private set;
|
|
||||||
} = new Dictionary<int, (IIngredientModel, int)>();
|
|
||||||
|
|
||||||
public static Canned? Create(CannedBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Canned()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
CannedName = model.CannedName,
|
|
||||||
Price = model.Price,
|
|
||||||
CannedIngredients = model.CannedIngredients
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(CannedBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CannedName = model.CannedName;
|
|
||||||
Price = model.Price;
|
|
||||||
CannedIngredients = model.CannedIngredients;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CannedViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
CannedName = CannedName,
|
|
||||||
Price = Price,
|
|
||||||
CannedIngredients = CannedIngredients
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryDataModels.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryListImplement.Models
|
|
||||||
{
|
|
||||||
public class Ingredient : IIngredientModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string IngredientName { get; private set; } = string.Empty;
|
|
||||||
public double Cost { get; set; }
|
|
||||||
public static Ingredient? Create(IngredientBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Ingredient()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
IngredientName = model.IngredientName,
|
|
||||||
Cost = model.Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(IngredientBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
IngredientName = model.IngredientName;
|
|
||||||
Cost = model.Cost;
|
|
||||||
}
|
|
||||||
public IngredientViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
IngredientName = IngredientName,
|
|
||||||
Cost = Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryDataModels.Enums;
|
|
||||||
using FishFactoryDataModels.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryListImplement.Models
|
|
||||||
{
|
|
||||||
public class Order : IOrderModel
|
|
||||||
{
|
|
||||||
public int CannedId { get; private set; }
|
|
||||||
public string CannedName { get; private set; } = string.Empty;
|
|
||||||
public int Count { get; private set; }
|
|
||||||
public double Sum { get; private set; }
|
|
||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
|
||||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
|
||||||
public DateTime? DateImplement { get; private set; }
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Order
|
|
||||||
{
|
|
||||||
CannedId = model.CannedId,
|
|
||||||
CannedName = model.CannedName,
|
|
||||||
Count = model.Count,
|
|
||||||
Sum = model.Sum,
|
|
||||||
Status = model.Status,
|
|
||||||
DateCreate = model.DateCreate,
|
|
||||||
DateImplement = model.DateImplement,
|
|
||||||
Id = model.Id,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CannedId = model.CannedId;
|
|
||||||
CannedName = model.CannedName;
|
|
||||||
Count = model.Count;
|
|
||||||
Sum = model.Sum;
|
|
||||||
Status = model.Status;
|
|
||||||
DateCreate = model.DateCreate;
|
|
||||||
DateImplement = model.DateImplement;
|
|
||||||
Id = model.Id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
CannedId = CannedId,
|
|
||||||
CannedName = CannedName,
|
|
||||||
Count = Count,
|
|
||||||
Sum = Sum,
|
|
||||||
DateCreate = DateCreate,
|
|
||||||
DateImplement = DateImplement,
|
|
||||||
Id = Id,
|
|
||||||
Status = Status,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,25 +8,4 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.3">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.3">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\FishFactoryBusinessLogic\FishFactoryBusinessLogic.csproj" />
|
|
||||||
<ProjectReference Include="..\FishFactoryDatabaseImplement\FishFactoryDatabaseImplement.csproj" />
|
|
||||||
<ProjectReference Include="..\FishFactoryFileImplement\FishFactoryFileImplement.csproj" />
|
|
||||||
<ProjectReference Include="..\FishFactoryListImplement\FishFactoryListImplement.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
39
FishFactory/FishFactoryView/Form1.Designer.cs
generated
Normal file
39
FishFactory/FishFactoryView/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace FishFactoryView
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Text = "Form1";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
10
FishFactory/FishFactoryView/Form1.cs
Normal file
10
FishFactory/FishFactoryView/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace FishFactoryView
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
FishFactory/FishFactoryView/Form1.resx
Normal file
120
FishFactory/FishFactoryView/Form1.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
247
FishFactory/FishFactoryView/FormCanned.Designer.cs
generated
247
FishFactory/FishFactoryView/FormCanned.Designer.cs
generated
@ -1,247 +0,0 @@
|
|||||||
namespace FishFactoryView
|
|
||||||
{
|
|
||||||
partial class FormCanned
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.textBoxPrice = new System.Windows.Forms.TextBox();
|
|
||||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelPrice = new System.Windows.Forms.Label();
|
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
|
||||||
this.groupBoxIngredients = new System.Windows.Forms.GroupBox();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDelete = new System.Windows.Forms.Button();
|
|
||||||
this.buttonEdit = new System.Windows.Forms.Button();
|
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.ColumnIngredientName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.groupBoxIngredients.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// textBoxPrice
|
|
||||||
//
|
|
||||||
this.textBoxPrice.Location = new System.Drawing.Point(90, 36);
|
|
||||||
this.textBoxPrice.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxPrice.Name = "textBoxPrice";
|
|
||||||
this.textBoxPrice.ReadOnly = true;
|
|
||||||
this.textBoxPrice.Size = new System.Drawing.Size(138, 23);
|
|
||||||
this.textBoxPrice.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
this.textBoxName.Location = new System.Drawing.Point(90, 11);
|
|
||||||
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxName.Name = "textBoxName";
|
|
||||||
this.textBoxName.Size = new System.Drawing.Size(276, 23);
|
|
||||||
this.textBoxName.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// labelPrice
|
|
||||||
//
|
|
||||||
this.labelPrice.AutoSize = true;
|
|
||||||
this.labelPrice.Location = new System.Drawing.Point(14, 41);
|
|
||||||
this.labelPrice.Name = "labelPrice";
|
|
||||||
this.labelPrice.Size = new System.Drawing.Size(70, 15);
|
|
||||||
this.labelPrice.TabIndex = 5;
|
|
||||||
this.labelPrice.Text = "Стоимость:";
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
this.labelName.AutoSize = true;
|
|
||||||
this.labelName.Location = new System.Drawing.Point(14, 14);
|
|
||||||
this.labelName.Name = "labelName";
|
|
||||||
this.labelName.Size = new System.Drawing.Size(62, 15);
|
|
||||||
this.labelName.TabIndex = 4;
|
|
||||||
this.labelName.Text = "Название:";
|
|
||||||
//
|
|
||||||
// groupBoxIngredients
|
|
||||||
//
|
|
||||||
this.groupBoxIngredients.Controls.Add(this.buttonCancel);
|
|
||||||
this.groupBoxIngredients.Controls.Add(this.buttonSave);
|
|
||||||
this.groupBoxIngredients.Controls.Add(this.buttonUpdate);
|
|
||||||
this.groupBoxIngredients.Controls.Add(this.buttonDelete);
|
|
||||||
this.groupBoxIngredients.Controls.Add(this.buttonEdit);
|
|
||||||
this.groupBoxIngredients.Controls.Add(this.buttonAdd);
|
|
||||||
this.groupBoxIngredients.Controls.Add(this.dataGridView);
|
|
||||||
this.groupBoxIngredients.Dock = System.Windows.Forms.DockStyle.Bottom;
|
|
||||||
this.groupBoxIngredients.Location = new System.Drawing.Point(0, 66);
|
|
||||||
this.groupBoxIngredients.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.groupBoxIngredients.Name = "groupBoxIngredients";
|
|
||||||
this.groupBoxIngredients.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.groupBoxIngredients.Size = new System.Drawing.Size(592, 255);
|
|
||||||
this.groupBoxIngredients.TabIndex = 8;
|
|
||||||
this.groupBoxIngredients.TabStop = false;
|
|
||||||
this.groupBoxIngredients.Text = "Ингредиенты";
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(490, 222);
|
|
||||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(79, 22);
|
|
||||||
this.buttonCancel.TabIndex = 6;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(405, 222);
|
|
||||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(79, 22);
|
|
||||||
this.buttonSave.TabIndex = 5;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
this.buttonUpdate.Location = new System.Drawing.Point(504, 126);
|
|
||||||
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonUpdate.Name = "buttonUpdate";
|
|
||||||
this.buttonUpdate.Size = new System.Drawing.Size(79, 22);
|
|
||||||
this.buttonUpdate.TabIndex = 4;
|
|
||||||
this.buttonUpdate.Text = "Обновить";
|
|
||||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
|
|
||||||
//
|
|
||||||
// buttonDelete
|
|
||||||
//
|
|
||||||
this.buttonDelete.Location = new System.Drawing.Point(504, 100);
|
|
||||||
this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonDelete.Name = "buttonDelete";
|
|
||||||
this.buttonDelete.Size = new System.Drawing.Size(79, 22);
|
|
||||||
this.buttonDelete.TabIndex = 3;
|
|
||||||
this.buttonDelete.Text = "Удалить";
|
|
||||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
|
|
||||||
//
|
|
||||||
// buttonEdit
|
|
||||||
//
|
|
||||||
this.buttonEdit.Location = new System.Drawing.Point(504, 74);
|
|
||||||
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonEdit.Name = "buttonEdit";
|
|
||||||
this.buttonEdit.Size = new System.Drawing.Size(79, 22);
|
|
||||||
this.buttonEdit.TabIndex = 2;
|
|
||||||
this.buttonEdit.Text = "Изменить";
|
|
||||||
this.buttonEdit.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click);
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(504, 48);
|
|
||||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(79, 22);
|
|
||||||
this.buttonAdd.TabIndex = 1;
|
|
||||||
this.buttonAdd.Text = "Добавить";
|
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
|
||||||
this.ID,
|
|
||||||
this.ColumnIngredientName,
|
|
||||||
this.ColumnCount});
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(5, 20);
|
|
||||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(493, 182);
|
|
||||||
this.dataGridView.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// ID
|
|
||||||
//
|
|
||||||
this.ID.HeaderText = "ID";
|
|
||||||
this.ID.MinimumWidth = 6;
|
|
||||||
this.ID.Name = "ID";
|
|
||||||
this.ID.Visible = false;
|
|
||||||
this.ID.Width = 125;
|
|
||||||
//
|
|
||||||
// ColumnIngredientName
|
|
||||||
//
|
|
||||||
this.ColumnIngredientName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
|
|
||||||
this.ColumnIngredientName.HeaderText = "Ингредиент";
|
|
||||||
this.ColumnIngredientName.MinimumWidth = 6;
|
|
||||||
this.ColumnIngredientName.Name = "ColumnIngredientName";
|
|
||||||
this.ColumnIngredientName.Resizable = System.Windows.Forms.DataGridViewTriState.True;
|
|
||||||
this.ColumnIngredientName.Width = 312;
|
|
||||||
//
|
|
||||||
// ColumnCount
|
|
||||||
//
|
|
||||||
this.ColumnCount.HeaderText = "Количество";
|
|
||||||
this.ColumnCount.MinimumWidth = 6;
|
|
||||||
this.ColumnCount.Name = "ColumnCount";
|
|
||||||
this.ColumnCount.Width = 125;
|
|
||||||
//
|
|
||||||
// FormCanned
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(592, 321);
|
|
||||||
this.Controls.Add(this.groupBoxIngredients);
|
|
||||||
this.Controls.Add(this.textBoxPrice);
|
|
||||||
this.Controls.Add(this.textBoxName);
|
|
||||||
this.Controls.Add(this.labelPrice);
|
|
||||||
this.Controls.Add(this.labelName);
|
|
||||||
this.Name = "FormCanned";
|
|
||||||
this.Text = "Консервы";
|
|
||||||
this.Load += new System.EventHandler(this.FormSushi_Load);
|
|
||||||
this.groupBoxIngredients.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private TextBox textBoxPrice;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private Label labelPrice;
|
|
||||||
private Label labelName;
|
|
||||||
private GroupBox groupBoxIngredients;
|
|
||||||
private Button buttonUpdate;
|
|
||||||
private Button buttonDelete;
|
|
||||||
private Button buttonEdit;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Button buttonSave;
|
|
||||||
private DataGridViewTextBoxColumn ID;
|
|
||||||
private DataGridViewTextBoxColumn ColumnIngredientName;
|
|
||||||
private DataGridViewTextBoxColumn ColumnCount;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,206 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using FishFactoryDataModels.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryView
|
|
||||||
{
|
|
||||||
public partial class FormCanned : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly ICannedLogic _logic;
|
|
||||||
private int? _id;
|
|
||||||
private Dictionary<int, (IIngredientModel, int)> _cannedIngredients;
|
|
||||||
public int Id { set { _id = value; } }
|
|
||||||
public FormCanned(ILogger<FormCanned> logger, ICannedLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
_cannedIngredients = new Dictionary<int, (IIngredientModel, int)>();
|
|
||||||
}
|
|
||||||
private void FormSushi_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_id.HasValue)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка консервы");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var view = _logic.ReadElement(new CannedSearchModel
|
|
||||||
{
|
|
||||||
Id = _id.Value
|
|
||||||
});
|
|
||||||
if (view != null)
|
|
||||||
{
|
|
||||||
textBoxName.Text = view.CannedName;
|
|
||||||
textBoxPrice.Text = view.Price.ToString();
|
|
||||||
_cannedIngredients = view.CannedIngredients ?? new Dictionary<int, (IIngredientModel, int)>();
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки консервы");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка ингредиента консервы");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_cannedIngredients != null)
|
|
||||||
{
|
|
||||||
dataGridView.Rows.Clear();
|
|
||||||
foreach (var sc in _cannedIngredients)
|
|
||||||
{
|
|
||||||
dataGridView.Rows.Add(new object[] { sc.Key, sc.Value.Item1.IngredientName, sc.Value.Item2 });
|
|
||||||
}
|
|
||||||
textBoxPrice.Text = CalcPrice().ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки ингредиента консервы");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCannedIngredients));
|
|
||||||
if (service is FormCannedIngredients form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (form.IngredientModel == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Добавление нового ингредиента: { IngredientName} - { Count}", form.IngredientModel.IngredientName, form.Count);
|
|
||||||
if (_cannedIngredients.ContainsKey(form.Id))
|
|
||||||
{
|
|
||||||
_cannedIngredients[form.Id] = (form.IngredientModel,
|
|
||||||
form.Count);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_cannedIngredients.Add(form.Id, (form.IngredientModel,
|
|
||||||
form.Count));
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCannedIngredients));
|
|
||||||
if (service is FormCannedIngredients form)
|
|
||||||
{
|
|
||||||
int id =
|
|
||||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
|
||||||
form.Id = id;
|
|
||||||
form.Count = _cannedIngredients[id].Item2;
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (form.IngredientModel == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Изменение ингредиента: { IngredientName} - { Count} ", form.IngredientModel.IngredientName, form.Count);
|
|
||||||
_cannedIngredients[form.Id] = (form.IngredientModel, form.Count);
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonDel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
|
||||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление ингредиента: { IngredientName} - { Count} ",
|
|
||||||
dataGridView.SelectedRows[0].Cells[1].Value); _cannedIngredients?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonRef_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните название", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(textBoxPrice.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_cannedIngredients == null || _cannedIngredients.Count == 0)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните ингредиенты", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Сохранение консервы");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var model = new CannedBindingModel
|
|
||||||
{
|
|
||||||
Id = _id ?? 0,
|
|
||||||
CannedName = textBoxName.Text,
|
|
||||||
Price = Convert.ToDouble(textBoxPrice.Text),
|
|
||||||
CannedIngredients = _cannedIngredients
|
|
||||||
};
|
|
||||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка сохранения консервы");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
private double CalcPrice()
|
|
||||||
{
|
|
||||||
double price = 0;
|
|
||||||
foreach (var elem in _cannedIngredients)
|
|
||||||
{
|
|
||||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
|
||||||
}
|
|
||||||
return Math.Round(price * 1.1, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<metadata name="ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnIngredientName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
@ -1,123 +0,0 @@
|
|||||||
namespace FishFactoryView
|
|
||||||
{
|
|
||||||
partial class FormCannedIngredients
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
|
||||||
this.comboBoxIngredient = new System.Windows.Forms.ComboBox();
|
|
||||||
this.labelCount = new System.Windows.Forms.Label();
|
|
||||||
this.labelIngredient = new System.Windows.Forms.Label();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(319, 80);
|
|
||||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(80, 22);
|
|
||||||
this.buttonCancel.TabIndex = 11;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(233, 80);
|
|
||||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(80, 22);
|
|
||||||
this.buttonSave.TabIndex = 10;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// textBoxCount
|
|
||||||
//
|
|
||||||
this.textBoxCount.Location = new System.Drawing.Point(116, 43);
|
|
||||||
this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxCount.Name = "textBoxCount";
|
|
||||||
this.textBoxCount.Size = new System.Drawing.Size(283, 23);
|
|
||||||
this.textBoxCount.TabIndex = 9;
|
|
||||||
//
|
|
||||||
// comboBoxIngredient
|
|
||||||
//
|
|
||||||
this.comboBoxIngredient.FormattingEnabled = true;
|
|
||||||
this.comboBoxIngredient.Location = new System.Drawing.Point(116, 11);
|
|
||||||
this.comboBoxIngredient.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.comboBoxIngredient.Name = "comboBoxIngredient";
|
|
||||||
this.comboBoxIngredient.Size = new System.Drawing.Size(282, 23);
|
|
||||||
this.comboBoxIngredient.TabIndex = 8;
|
|
||||||
//
|
|
||||||
// labelCount
|
|
||||||
//
|
|
||||||
this.labelCount.AutoSize = true;
|
|
||||||
this.labelCount.Location = new System.Drawing.Point(10, 46);
|
|
||||||
this.labelCount.Name = "labelCount";
|
|
||||||
this.labelCount.Size = new System.Drawing.Size(75, 15);
|
|
||||||
this.labelCount.TabIndex = 7;
|
|
||||||
this.labelCount.Text = "Количество:";
|
|
||||||
//
|
|
||||||
// labelIngredient
|
|
||||||
//
|
|
||||||
this.labelIngredient.AutoSize = true;
|
|
||||||
this.labelIngredient.Location = new System.Drawing.Point(10, 14);
|
|
||||||
this.labelIngredient.Name = "labelIngredient";
|
|
||||||
this.labelIngredient.Size = new System.Drawing.Size(72, 15);
|
|
||||||
this.labelIngredient.TabIndex = 6;
|
|
||||||
this.labelIngredient.Text = "Ингредиент";
|
|
||||||
//
|
|
||||||
// FormCannedIngredients
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(410, 115);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.buttonSave);
|
|
||||||
this.Controls.Add(this.textBoxCount);
|
|
||||||
this.Controls.Add(this.comboBoxIngredient);
|
|
||||||
this.Controls.Add(this.labelCount);
|
|
||||||
this.Controls.Add(this.labelIngredient);
|
|
||||||
this.Name = "FormCannedIngredients";
|
|
||||||
this.Text = "Ингредиент консервы";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Button buttonSave;
|
|
||||||
private TextBox textBoxCount;
|
|
||||||
private ComboBox comboBoxIngredient;
|
|
||||||
private Label labelCount;
|
|
||||||
private Label labelIngredient;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,79 +0,0 @@
|
|||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
|
||||||
using FishFactoryContracts.ViewModels;
|
|
||||||
using FishFactoryDataModels.Models;
|
|
||||||
|
|
||||||
namespace FishFactoryView
|
|
||||||
{
|
|
||||||
public partial class FormCannedIngredients : Form
|
|
||||||
{
|
|
||||||
private readonly List<IngredientViewModel>? _list;
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Convert.ToInt32(comboBoxIngredient.SelectedValue);
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
comboBoxIngredient.SelectedValue = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public IIngredientModel? IngredientModel
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_list == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var elem in _list)
|
|
||||||
{
|
|
||||||
if (elem.Id == Id)
|
|
||||||
{
|
|
||||||
return elem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public int Count
|
|
||||||
{
|
|
||||||
get { return Convert.ToInt32(textBoxCount.Text); }
|
|
||||||
set { textBoxCount.Text = value.ToString(); }
|
|
||||||
}
|
|
||||||
public FormCannedIngredients(IIngredientLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_list = logic.ReadList(null);
|
|
||||||
if (_list != null)
|
|
||||||
{
|
|
||||||
comboBoxIngredient.DisplayMember = "IngredientName";
|
|
||||||
comboBoxIngredient.ValueMember = "Id";
|
|
||||||
comboBoxIngredient.DataSource = _list;
|
|
||||||
comboBoxIngredient.SelectedItem = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните поле 'Количество'", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (comboBoxIngredient.SelectedValue == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Выберите ингредиент", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
150
FishFactory/FishFactoryView/FormCreateOrder.Designer.cs
generated
150
FishFactory/FishFactoryView/FormCreateOrder.Designer.cs
generated
@ -1,150 +0,0 @@
|
|||||||
namespace FishFactoryView
|
|
||||||
{
|
|
||||||
partial class FormCreateOrder
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.textBoxSum = new System.Windows.Forms.TextBox();
|
|
||||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
|
||||||
this.comboBoxCanned = new System.Windows.Forms.ComboBox();
|
|
||||||
this.labelSum = new System.Windows.Forms.Label();
|
|
||||||
this.labelCount = new System.Windows.Forms.Label();
|
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(241, 90);
|
|
||||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(82, 22);
|
|
||||||
this.buttonCancel.TabIndex = 15;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(153, 90);
|
|
||||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(82, 22);
|
|
||||||
this.buttonSave.TabIndex = 14;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// textBoxSum
|
|
||||||
//
|
|
||||||
this.textBoxSum.Location = new System.Drawing.Point(93, 63);
|
|
||||||
this.textBoxSum.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxSum.Name = "textBoxSum";
|
|
||||||
this.textBoxSum.ReadOnly = true;
|
|
||||||
this.textBoxSum.Size = new System.Drawing.Size(230, 23);
|
|
||||||
this.textBoxSum.TabIndex = 13;
|
|
||||||
//
|
|
||||||
// textBoxCount
|
|
||||||
//
|
|
||||||
this.textBoxCount.Location = new System.Drawing.Point(93, 36);
|
|
||||||
this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxCount.Name = "textBoxCount";
|
|
||||||
this.textBoxCount.Size = new System.Drawing.Size(230, 23);
|
|
||||||
this.textBoxCount.TabIndex = 12;
|
|
||||||
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
|
|
||||||
//
|
|
||||||
// comboBoxCanned
|
|
||||||
//
|
|
||||||
this.comboBoxCanned.FormattingEnabled = true;
|
|
||||||
this.comboBoxCanned.Location = new System.Drawing.Point(93, 9);
|
|
||||||
this.comboBoxCanned.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.comboBoxCanned.Name = "comboBoxCanned";
|
|
||||||
this.comboBoxCanned.Size = new System.Drawing.Size(230, 23);
|
|
||||||
this.comboBoxCanned.TabIndex = 11;
|
|
||||||
this.comboBoxCanned.SelectedIndexChanged += new System.EventHandler(this.ComboBoxCanned_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// labelSum
|
|
||||||
//
|
|
||||||
this.labelSum.AutoSize = true;
|
|
||||||
this.labelSum.Location = new System.Drawing.Point(12, 63);
|
|
||||||
this.labelSum.Name = "labelSum";
|
|
||||||
this.labelSum.Size = new System.Drawing.Size(48, 15);
|
|
||||||
this.labelSum.TabIndex = 10;
|
|
||||||
this.labelSum.Text = "Сумма:";
|
|
||||||
//
|
|
||||||
// labelCount
|
|
||||||
//
|
|
||||||
this.labelCount.AutoSize = true;
|
|
||||||
this.labelCount.Location = new System.Drawing.Point(12, 36);
|
|
||||||
this.labelCount.Name = "labelCount";
|
|
||||||
this.labelCount.Size = new System.Drawing.Size(75, 15);
|
|
||||||
this.labelCount.TabIndex = 9;
|
|
||||||
this.labelCount.Text = "Количество:";
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
this.labelName.AutoSize = true;
|
|
||||||
this.labelName.Location = new System.Drawing.Point(12, 9);
|
|
||||||
this.labelName.Name = "labelName";
|
|
||||||
this.labelName.Size = new System.Drawing.Size(65, 15);
|
|
||||||
this.labelName.TabIndex = 8;
|
|
||||||
this.labelName.Text = "Консервы:";
|
|
||||||
//
|
|
||||||
// FormCreateOrder
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(343, 128);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.buttonSave);
|
|
||||||
this.Controls.Add(this.textBoxSum);
|
|
||||||
this.Controls.Add(this.textBoxCount);
|
|
||||||
this.Controls.Add(this.comboBoxCanned);
|
|
||||||
this.Controls.Add(this.labelSum);
|
|
||||||
this.Controls.Add(this.labelCount);
|
|
||||||
this.Controls.Add(this.labelName);
|
|
||||||
this.Name = "FormCreateOrder";
|
|
||||||
this.Text = "Заказ";
|
|
||||||
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Button buttonSave;
|
|
||||||
private TextBox textBoxSum;
|
|
||||||
private TextBox textBoxCount;
|
|
||||||
private ComboBox comboBoxCanned;
|
|
||||||
private Label labelSum;
|
|
||||||
private Label labelCount;
|
|
||||||
private Label labelName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,117 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
|
|
||||||
namespace FishFactoryView
|
|
||||||
{
|
|
||||||
public partial class FormCreateOrder : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly ICannedLogic _logicS;
|
|
||||||
private readonly IOrderLogic _logicO;
|
|
||||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, ICannedLogic logicS, IOrderLogic logicO)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logicS = logicS;
|
|
||||||
_logicO = logicO;
|
|
||||||
}
|
|
||||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка консервы для заказа");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _logicS.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
comboBoxCanned.DisplayMember = "CannedName";
|
|
||||||
comboBoxCanned.ValueMember = "Id";
|
|
||||||
comboBoxCanned.DataSource = list;
|
|
||||||
comboBoxCanned.SelectedItem = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки списка консервы");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void CalcSum()
|
|
||||||
{
|
|
||||||
if (comboBoxCanned.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(comboBoxCanned.SelectedValue);
|
|
||||||
var product = _logicS.ReadElement(new CannedSearchModel
|
|
||||||
{
|
|
||||||
Id = id
|
|
||||||
});
|
|
||||||
int count = Convert.ToInt32(textBoxCount.Text);
|
|
||||||
textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
|
|
||||||
_logger.LogInformation("Расчет суммы заказа");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка расчета суммы заказа");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void TextBoxCount_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CalcSum();
|
|
||||||
}
|
|
||||||
private void ComboBoxCanned_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CalcSum();
|
|
||||||
}
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните поле 'Количество'", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (comboBoxCanned.SelectedValue == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Выберите консерву", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Создание заказа");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
|
||||||
{
|
|
||||||
CannedId = Convert.ToInt32(comboBoxCanned.SelectedValue),
|
|
||||||
CannedName = comboBoxCanned.Text,
|
|
||||||
Count = Convert.ToInt32(textBoxCount.Text),
|
|
||||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
|
||||||
});
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка создания заказа");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
124
FishFactory/FishFactoryView/FormIngredient.Designer.cs
generated
124
FishFactory/FishFactoryView/FormIngredient.Designer.cs
generated
@ -1,124 +0,0 @@
|
|||||||
namespace FishFactoryView
|
|
||||||
{
|
|
||||||
partial class FormIngredient
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.textBoxCost = new System.Windows.Forms.TextBox();
|
|
||||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
|
||||||
this.labelPrice = new System.Windows.Forms.Label();
|
|
||||||
this.labelBlankName = new System.Windows.Forms.Label();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(200, 73);
|
|
||||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(82, 22);
|
|
||||||
this.buttonCancel.TabIndex = 11;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(112, 73);
|
|
||||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(82, 22);
|
|
||||||
this.buttonSave.TabIndex = 10;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// textBoxCost
|
|
||||||
//
|
|
||||||
this.textBoxCost.Location = new System.Drawing.Point(111, 38);
|
|
||||||
this.textBoxCost.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxCost.Name = "textBoxCost";
|
|
||||||
this.textBoxCost.Size = new System.Drawing.Size(183, 23);
|
|
||||||
this.textBoxCost.TabIndex = 9;
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
this.textBoxName.Location = new System.Drawing.Point(111, 11);
|
|
||||||
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.textBoxName.Name = "textBoxName";
|
|
||||||
this.textBoxName.Size = new System.Drawing.Size(329, 23);
|
|
||||||
this.textBoxName.TabIndex = 8;
|
|
||||||
//
|
|
||||||
// labelPrice
|
|
||||||
//
|
|
||||||
this.labelPrice.AutoSize = true;
|
|
||||||
this.labelPrice.Location = new System.Drawing.Point(12, 37);
|
|
||||||
this.labelPrice.Name = "labelPrice";
|
|
||||||
this.labelPrice.Size = new System.Drawing.Size(38, 15);
|
|
||||||
this.labelPrice.TabIndex = 7;
|
|
||||||
this.labelPrice.Text = "Цена:";
|
|
||||||
//
|
|
||||||
// labelBlankName
|
|
||||||
//
|
|
||||||
this.labelBlankName.AutoSize = true;
|
|
||||||
this.labelBlankName.Location = new System.Drawing.Point(12, 14);
|
|
||||||
this.labelBlankName.Name = "labelBlankName";
|
|
||||||
this.labelBlankName.Size = new System.Drawing.Size(62, 15);
|
|
||||||
this.labelBlankName.TabIndex = 6;
|
|
||||||
this.labelBlankName.Text = "Название:";
|
|
||||||
//
|
|
||||||
// FormIngredient
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(448, 106);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.buttonSave);
|
|
||||||
this.Controls.Add(this.textBoxCost);
|
|
||||||
this.Controls.Add(this.textBoxName);
|
|
||||||
this.Controls.Add(this.labelPrice);
|
|
||||||
this.Controls.Add(this.labelBlankName);
|
|
||||||
this.Name = "FormIngredient";
|
|
||||||
this.Text = "Ингредиент";
|
|
||||||
this.Load += new System.EventHandler(this.FormIngredient_Load);
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Button buttonSave;
|
|
||||||
private TextBox textBoxCost;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private Label labelPrice;
|
|
||||||
private Label labelBlankName;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.SearchModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
|
||||||
|
|
||||||
namespace FishFactoryView
|
|
||||||
{
|
|
||||||
public partial class FormIngredient : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IIngredientLogic _logic;
|
|
||||||
private int? _id;
|
|
||||||
public int Id { set { _id = value; } }
|
|
||||||
|
|
||||||
public FormIngredient(ILogger<FormIngredient> logger, IIngredientLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormIngredient_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_id.HasValue)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение ингредиента");
|
|
||||||
var view = _logic.ReadElement(new IngredientSearchModel
|
|
||||||
{
|
|
||||||
Id = _id.Value
|
|
||||||
});
|
|
||||||
if (view != null)
|
|
||||||
{
|
|
||||||
textBoxName.Text = view.IngredientName;
|
|
||||||
textBoxCost.Text = view.Cost.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка получения ингредиента");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Сохранение ингредиента");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var model = new IngredientBindingModel
|
|
||||||
{
|
|
||||||
Id = _id ?? 0,
|
|
||||||
IngredientName = textBoxName.Text,
|
|
||||||
Cost = Convert.ToDouble(textBoxCost.Text)
|
|
||||||
};
|
|
||||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка сохранения ингредиента");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
122
FishFactory/FishFactoryView/FormIngredients.Designer.cs
generated
122
FishFactory/FishFactoryView/FormIngredients.Designer.cs
generated
@ -1,122 +0,0 @@
|
|||||||
namespace FishFactoryView
|
|
||||||
{
|
|
||||||
partial class FormIngredients
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDelete = new System.Windows.Forms.Button();
|
|
||||||
this.buttonEdit = new System.Windows.Forms.Button();
|
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
this.buttonUpdate.Location = new System.Drawing.Point(432, 186);
|
|
||||||
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonUpdate.Name = "buttonUpdate";
|
|
||||||
this.buttonUpdate.Size = new System.Drawing.Size(130, 22);
|
|
||||||
this.buttonUpdate.TabIndex = 9;
|
|
||||||
this.buttonUpdate.Text = "Обновить";
|
|
||||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
|
|
||||||
//
|
|
||||||
// buttonDelete
|
|
||||||
//
|
|
||||||
this.buttonDelete.Location = new System.Drawing.Point(432, 160);
|
|
||||||
this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonDelete.Name = "buttonDelete";
|
|
||||||
this.buttonDelete.Size = new System.Drawing.Size(130, 22);
|
|
||||||
this.buttonDelete.TabIndex = 8;
|
|
||||||
this.buttonDelete.Text = "Удалить";
|
|
||||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
|
|
||||||
//
|
|
||||||
// buttonEdit
|
|
||||||
//
|
|
||||||
this.buttonEdit.Location = new System.Drawing.Point(432, 134);
|
|
||||||
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonEdit.Name = "buttonEdit";
|
|
||||||
this.buttonEdit.Size = new System.Drawing.Size(130, 22);
|
|
||||||
this.buttonEdit.TabIndex = 7;
|
|
||||||
this.buttonEdit.Text = "Изменить";
|
|
||||||
this.buttonEdit.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click);
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(432, 108);
|
|
||||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(130, 22);
|
|
||||||
this.buttonAdd.TabIndex = 6;
|
|
||||||
this.buttonAdd.Text = "Добавить";
|
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
|
|
||||||
this.dataGridView.GridColor = System.Drawing.Color.White;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(426, 348);
|
|
||||||
this.dataGridView.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// FormIngredients
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(571, 348);
|
|
||||||
this.Controls.Add(this.dataGridView);
|
|
||||||
this.Controls.Add(this.buttonUpdate);
|
|
||||||
this.Controls.Add(this.buttonDelete);
|
|
||||||
this.Controls.Add(this.buttonEdit);
|
|
||||||
this.Controls.Add(this.buttonAdd);
|
|
||||||
this.Name = "FormIngredients";
|
|
||||||
this.Text = "Ингредиенты";
|
|
||||||
this.Load += new System.EventHandler(this.FormIngredients_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonUpdate;
|
|
||||||
private Button buttonDelete;
|
|
||||||
private Button buttonEdit;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,99 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
|
||||||
|
|
||||||
namespace FishFactoryView
|
|
||||||
{
|
|
||||||
public partial class FormIngredients : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IIngredientLogic _logic;
|
|
||||||
public FormIngredients(ILogger<FormIngredients> logger, IIngredientLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
private void FormIngredients_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _logic.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["IngredientName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка ингредиентов");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки ингредиентов");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormIngredient));
|
|
||||||
if (service is FormIngredient form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormIngredient));
|
|
||||||
if (service is FormIngredient form)
|
|
||||||
{
|
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonDel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Удаление ингредиента");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!_logic.Delete(new IngredientBindingModel
|
|
||||||
{
|
|
||||||
Id = id
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка удаления ингредиента");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonRef_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
122
FishFactory/FishFactoryView/FormListCanned.Designer.cs
generated
122
FishFactory/FishFactoryView/FormListCanned.Designer.cs
generated
@ -1,122 +0,0 @@
|
|||||||
namespace FishFactoryView
|
|
||||||
{
|
|
||||||
partial class FormListCanned
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDelete = new System.Windows.Forms.Button();
|
|
||||||
this.buttonEdit = new System.Windows.Forms.Button();
|
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
|
|
||||||
this.dataGridView.GridColor = System.Drawing.Color.White;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(426, 345);
|
|
||||||
this.dataGridView.TabIndex = 10;
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
this.buttonUpdate.Location = new System.Drawing.Point(432, 183);
|
|
||||||
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonUpdate.Name = "buttonUpdate";
|
|
||||||
this.buttonUpdate.Size = new System.Drawing.Size(130, 22);
|
|
||||||
this.buttonUpdate.TabIndex = 14;
|
|
||||||
this.buttonUpdate.Text = "Обновить";
|
|
||||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click);
|
|
||||||
//
|
|
||||||
// buttonDelete
|
|
||||||
//
|
|
||||||
this.buttonDelete.Location = new System.Drawing.Point(432, 157);
|
|
||||||
this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonDelete.Name = "buttonDelete";
|
|
||||||
this.buttonDelete.Size = new System.Drawing.Size(130, 22);
|
|
||||||
this.buttonDelete.TabIndex = 13;
|
|
||||||
this.buttonDelete.Text = "Удалить";
|
|
||||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDelete_Click);
|
|
||||||
//
|
|
||||||
// buttonEdit
|
|
||||||
//
|
|
||||||
this.buttonEdit.Location = new System.Drawing.Point(432, 131);
|
|
||||||
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonEdit.Name = "buttonEdit";
|
|
||||||
this.buttonEdit.Size = new System.Drawing.Size(130, 22);
|
|
||||||
this.buttonEdit.TabIndex = 12;
|
|
||||||
this.buttonEdit.Text = "Изменить";
|
|
||||||
this.buttonEdit.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonEdit.Click += new System.EventHandler(this.ButtonEdit_Click);
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(432, 105);
|
|
||||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(130, 22);
|
|
||||||
this.buttonAdd.TabIndex = 11;
|
|
||||||
this.buttonAdd.Text = "Добавить";
|
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
|
||||||
//
|
|
||||||
// FormListCanned
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(570, 345);
|
|
||||||
this.Controls.Add(this.dataGridView);
|
|
||||||
this.Controls.Add(this.buttonUpdate);
|
|
||||||
this.Controls.Add(this.buttonDelete);
|
|
||||||
this.Controls.Add(this.buttonEdit);
|
|
||||||
this.Controls.Add(this.buttonAdd);
|
|
||||||
this.Name = "FormListCanned";
|
|
||||||
this.Text = "Список консерв";
|
|
||||||
this.Load += new System.EventHandler(this.FormDocuments_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
private Button buttonUpdate;
|
|
||||||
private Button buttonDelete;
|
|
||||||
private Button buttonEdit;
|
|
||||||
private Button buttonAdd;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,104 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
|
||||||
|
|
||||||
namespace FishFactoryView
|
|
||||||
{
|
|
||||||
public partial class FormListCanned : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly ICannedLogic _logic;
|
|
||||||
public FormListCanned(ILogger<FormListCanned> logger, ICannedLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormDocuments_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _logic.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["CannedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridView.Columns["CannedIngredients"].Visible = false;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка консервы");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки консервы");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCanned));
|
|
||||||
if (service is FormCanned form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonEdit_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCanned));
|
|
||||||
if (service is FormCanned form)
|
|
||||||
{
|
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Удаление консервы");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!_logic.Delete(new CannedBindingModel
|
|
||||||
{
|
|
||||||
Id = id
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка удаления консервы");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
182
FishFactory/FishFactoryView/FormMain.Designer.cs
generated
182
FishFactory/FishFactoryView/FormMain.Designer.cs
generated
@ -1,182 +0,0 @@
|
|||||||
namespace FishFactoryView
|
|
||||||
{
|
|
||||||
partial class FormMain
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
|
||||||
this.reference_booksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.ingredientsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.cannedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSetToFinish = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSetToDone = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSetToWork = new System.Windows.Forms.Button();
|
|
||||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
this.menuStrip.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// menuStrip
|
|
||||||
//
|
|
||||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.reference_booksToolStripMenuItem});
|
|
||||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.menuStrip.Name = "menuStrip";
|
|
||||||
this.menuStrip.Size = new System.Drawing.Size(975, 24);
|
|
||||||
this.menuStrip.TabIndex = 0;
|
|
||||||
this.menuStrip.Text = "menuStrip1";
|
|
||||||
//
|
|
||||||
// reference_booksToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.reference_booksToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.ingredientsToolStripMenuItem,
|
|
||||||
this.cannedToolStripMenuItem});
|
|
||||||
this.reference_booksToolStripMenuItem.Name = "reference_booksToolStripMenuItem";
|
|
||||||
this.reference_booksToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
|
||||||
this.reference_booksToolStripMenuItem.Text = "Справочники";
|
|
||||||
//
|
|
||||||
// ingredientsингредиентыToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.ingredientsToolStripMenuItem.Name = "ingredientsToolStripMenuItem";
|
|
||||||
this.ingredientsToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
|
|
||||||
this.ingredientsToolStripMenuItem.Text = "Ингредиенты";
|
|
||||||
this.ingredientsToolStripMenuItem.Click += new System.EventHandler(this.IngredientsToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// cannedToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.cannedToolStripMenuItem.Name = "cannedToolStripMenuItem";
|
|
||||||
this.cannedToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
|
|
||||||
this.cannedToolStripMenuItem.Text = "Консервы";
|
|
||||||
this.cannedToolStripMenuItem.Click += new System.EventHandler(this.CannedToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
this.buttonUpdate.Location = new System.Drawing.Point(780, 314);
|
|
||||||
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonUpdate.Name = "buttonUpdate";
|
|
||||||
this.buttonUpdate.Size = new System.Drawing.Size(170, 58);
|
|
||||||
this.buttonUpdate.TabIndex = 12;
|
|
||||||
this.buttonUpdate.Text = "Обновить";
|
|
||||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
|
|
||||||
//
|
|
||||||
// buttonSetToFinish
|
|
||||||
//
|
|
||||||
this.buttonSetToFinish.Location = new System.Drawing.Point(780, 252);
|
|
||||||
this.buttonSetToFinish.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonSetToFinish.Name = "buttonSetToFinish";
|
|
||||||
this.buttonSetToFinish.Size = new System.Drawing.Size(170, 58);
|
|
||||||
this.buttonSetToFinish.TabIndex = 11;
|
|
||||||
this.buttonSetToFinish.Text = "Заказ выдан";
|
|
||||||
this.buttonSetToFinish.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSetToFinish.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
|
|
||||||
//
|
|
||||||
// buttonSetToDone
|
|
||||||
//
|
|
||||||
this.buttonSetToDone.Location = new System.Drawing.Point(780, 190);
|
|
||||||
this.buttonSetToDone.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonSetToDone.Name = "buttonSetToDone";
|
|
||||||
this.buttonSetToDone.Size = new System.Drawing.Size(170, 58);
|
|
||||||
this.buttonSetToDone.TabIndex = 10;
|
|
||||||
this.buttonSetToDone.Text = "Заказ готов";
|
|
||||||
this.buttonSetToDone.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSetToDone.Click += new System.EventHandler(this.ButtonOrderReady_Click);
|
|
||||||
//
|
|
||||||
// buttonSetToWork
|
|
||||||
//
|
|
||||||
this.buttonSetToWork.Location = new System.Drawing.Point(780, 128);
|
|
||||||
this.buttonSetToWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonSetToWork.Name = "buttonSetToWork";
|
|
||||||
this.buttonSetToWork.Size = new System.Drawing.Size(170, 58);
|
|
||||||
this.buttonSetToWork.TabIndex = 9;
|
|
||||||
this.buttonSetToWork.Text = "Отдать на выполнение";
|
|
||||||
this.buttonSetToWork.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSetToWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
|
|
||||||
//
|
|
||||||
// buttonCreateOrder
|
|
||||||
//
|
|
||||||
this.buttonCreateOrder.Location = new System.Drawing.Point(780, 66);
|
|
||||||
this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonCreateOrder.Name = "buttonCreateOrder";
|
|
||||||
this.buttonCreateOrder.Size = new System.Drawing.Size(170, 58);
|
|
||||||
this.buttonCreateOrder.TabIndex = 8;
|
|
||||||
this.buttonCreateOrder.Text = "Создать заказ";
|
|
||||||
this.buttonCreateOrder.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(0, 24);
|
|
||||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(755, 426);
|
|
||||||
this.dataGridView.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// FormMain
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(975, 450);
|
|
||||||
this.Controls.Add(this.buttonUpdate);
|
|
||||||
this.Controls.Add(this.buttonSetToFinish);
|
|
||||||
this.Controls.Add(this.buttonSetToDone);
|
|
||||||
this.Controls.Add(this.buttonSetToWork);
|
|
||||||
this.Controls.Add(this.buttonCreateOrder);
|
|
||||||
this.Controls.Add(this.dataGridView);
|
|
||||||
this.Controls.Add(this.menuStrip);
|
|
||||||
this.MainMenuStrip = this.menuStrip;
|
|
||||||
this.Name = "FormMain";
|
|
||||||
this.Text = "Рыбный завод";
|
|
||||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
|
||||||
this.menuStrip.ResumeLayout(false);
|
|
||||||
this.menuStrip.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private MenuStrip menuStrip;
|
|
||||||
private ToolStripMenuItem reference_booksToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem ingredientsToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem cannedToolStripMenuItem;
|
|
||||||
private Button buttonUpdate;
|
|
||||||
private Button buttonSetToFinish;
|
|
||||||
private Button buttonSetToDone;
|
|
||||||
private Button buttonSetToWork;
|
|
||||||
private Button buttonCreateOrder;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,165 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using FishFactoryContracts.BindingModels;
|
|
||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
|
||||||
using FishFactoryDataModels.Enums;
|
|
||||||
|
|
||||||
namespace FishFactoryView
|
|
||||||
{
|
|
||||||
public partial class FormMain : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IOrderLogic _orderLogic;
|
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_orderLogic = orderLogic;
|
|
||||||
}
|
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _orderLogic.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["CannedId"].Visible = false;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void IngredientsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormIngredients));
|
|
||||||
if (service is FormIngredients form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void CannedToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormListCanned));
|
|
||||||
if (service is FormListCanned form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
|
||||||
if (service is FormCreateOrder form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
CannedId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["CannedId"].Value),
|
|
||||||
CannedName = dataGridView.SelectedRows[0].Cells["CannedName"].Value.ToString(),
|
|
||||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
|
||||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
|
||||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
|
||||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
|
||||||
});
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonOrderReady_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
CannedId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["CannedId"].Value),
|
|
||||||
CannedName = dataGridView.SelectedRows[0].Cells["CannedName"].Value.ToString(),
|
|
||||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
|
||||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
|
||||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
|
||||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
|
||||||
});
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
CannedId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["CannedId"].Value),
|
|
||||||
CannedName = dataGridView.SelectedRows[0].Cells["CannedName"].Value.ToString(),
|
|
||||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
|
||||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
|
||||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
|
||||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
|
||||||
});
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonRef_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
@ -1,20 +1,9 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using NLog.Extensions.Logging;
|
|
||||||
using FishFactoryBusinessLogic.BusinessLogics;
|
|
||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
|
||||||
using FishFactoryContracts.StoragesContracts;
|
|
||||||
using FishFactoryDatabaseImplement.Implements;
|
|
||||||
using FishFactoryView;
|
|
||||||
|
|
||||||
namespace FishFactoryView
|
namespace FishFactoryView
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
private static ServiceProvider? _serviceProvider;
|
|
||||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Главная точка входа для приложения.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
@ -22,34 +11,7 @@ namespace FishFactoryView
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
|
Application.Run(new Form1());
|
||||||
var services = new ServiceCollection();
|
|
||||||
ConfigureServices(services);
|
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddLogging(option =>
|
|
||||||
{
|
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
|
||||||
option.AddNLog("nlog.config");
|
|
||||||
});
|
|
||||||
services.AddTransient<IIngredientStorage, IngredientStorage>();
|
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
|
||||||
services.AddTransient<ICannedStorage, CannedStorage>();
|
|
||||||
services.AddTransient<IIngredientLogic, IngredientLogic>();
|
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
|
||||||
services.AddTransient<ICannedLogic, CannedLogic>();
|
|
||||||
services.AddTransient<FormMain>();
|
|
||||||
services.AddTransient<FormIngredient>();
|
|
||||||
services.AddTransient<FormIngredients>();
|
|
||||||
services.AddTransient<FormCreateOrder>();
|
|
||||||
services.AddTransient<FormCanned>();
|
|
||||||
services.AddTransient<FormCannedIngredients>();
|
|
||||||
services.AddTransient<FormListCanned>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user