Compare commits
No commits in common. "LabWork_03" and "main" have entirely different histories.
LabWork_03
...
main
1
.gitignore
vendored
1
.gitignore
vendored
@ -398,4 +398,3 @@ FodyWeavers.xsd
|
|||||||
# JetBrains Rider
|
# JetBrains Rider
|
||||||
*.sln.iml
|
*.sln.iml
|
||||||
|
|
||||||
/FoodOrders/AbstractFoodOrdersListImplement
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\AbstractFoodOrdersContracts\AbstractFoodOrdersContracts.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,114 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.StoragesContracts;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class ComponentLogic : IComponentLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IComponentStorage _componentStorage;
|
|
||||||
public ComponentLogic(ILogger<ComponentLogic> logger, IComponentStorage
|
|
||||||
componentStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_componentStorage = componentStorage;
|
|
||||||
}
|
|
||||||
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id);
|
|
||||||
var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? ReadElement(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}", model.ComponentName, model.Id);
|
|
||||||
var element = _componentStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
public bool Create(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_componentStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_componentStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Delete(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
|
||||||
if (_componentStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private void CheckModel(ComponentBindingModel model, bool withParams =
|
|
||||||
true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия компонента",
|
|
||||||
nameof(model.ComponentName));
|
|
||||||
}
|
|
||||||
if (model.Cost <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}. Id: { Id}", model.ComponentName, model.Cost, model.Id);
|
|
||||||
var element = _componentStorage.GetElement(new ComponentSearchModel{ ComponentName = model.ComponentName });
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,116 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.StoragesContracts;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class DishLogic : IDishLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IDishStorage _dishStorage;
|
|
||||||
public DishLogic(ILogger<DishLogic> logger, IDishStorage dishStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_dishStorage = dishStorage;
|
|
||||||
}
|
|
||||||
public List<DishViewModel>? ReadList(DishSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. DishName:{DishName}.Id:{ Id}", model?.DishName, model?.Id);
|
|
||||||
var list = model == null ? _dishStorage.GetFullList() : _dishStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
public DishViewModel? ReadElement(DishSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. DishName:{DishName}.Id:{ Id}", model.DishName, model.Id);
|
|
||||||
var element = _dishStorage.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(DishBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_dishStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Update(DishBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_dishStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Delete(DishBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
|
||||||
if (_dishStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private void CheckModel(DishBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.DishName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия изделия", nameof(model.DishName));
|
|
||||||
}
|
|
||||||
if (model.Price <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price));
|
|
||||||
}
|
|
||||||
if (model.DishComponents == null || model.DishComponents.Count == 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Перечень компонентов не может быть пустым", nameof(model.DishComponents));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Dish. DishName:{DishName}.Price:{Price}.Id: { Id}", model.DishName, model.Price, model.Id);
|
|
||||||
var element = _dishStorage.GetElement(new DishSearchModel
|
|
||||||
{
|
|
||||||
DishName = model.DishName
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Изделие с таким названием уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.StoragesContracts;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersDataModels.Enums;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersBusinessLogic.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 List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. OrderId:{Id}", model?.Id);
|
|
||||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
public bool CreateOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (model.Status != OrderStatus.Неизвестен)
|
|
||||||
return false;
|
|
||||||
model.Status = OrderStatus.Принят;
|
|
||||||
if (_orderStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return ChangeStatus(model, OrderStatus.Выполняется);
|
|
||||||
}
|
|
||||||
public bool FinishOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return ChangeStatus(model, OrderStatus.Готов);
|
|
||||||
}
|
|
||||||
public bool DeliveryOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return ChangeStatus(model, OrderStatus.Выдан);
|
|
||||||
}
|
|
||||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (model.Count <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Колличество изделий в заказе не может быть меньше 1", nameof(model.Count));
|
|
||||||
}
|
|
||||||
if (model.Sum <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Стоимость заказа на может быть меньше 1", nameof(model.Sum));
|
|
||||||
}
|
|
||||||
if (model.DateImplement.HasValue && model.DateImplement < model.DateCreate)
|
|
||||||
{
|
|
||||||
throw new ArithmeticException($"Дата выдачи заказа {model.DateImplement} не может быть раньше даты его создания {model.DateCreate}");
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Reinforced. ReinforcedId:{ReinforcedId}.Count:{Count}.Sum:{Sum}Id:{Id}",
|
|
||||||
model.DishId, model.Count, model.Sum, model.Id);
|
|
||||||
}
|
|
||||||
private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
var element = _orderStorage.GetElement(new OrderSearchModel()
|
|
||||||
{
|
|
||||||
Id = model.Id
|
|
||||||
});
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(element));
|
|
||||||
}
|
|
||||||
model.DateCreate = element.DateCreate;
|
|
||||||
model.DishId = element.DishId;
|
|
||||||
model.DateImplement = element.DateImplement;
|
|
||||||
model.Status = element.Status;
|
|
||||||
model.Count = element.Count;
|
|
||||||
model.Sum = element.Sum;
|
|
||||||
if (requiredStatus - model.Status == 1)
|
|
||||||
{
|
|
||||||
model.Status = requiredStatus;
|
|
||||||
if (model.Status == OrderStatus.Выдан)
|
|
||||||
model.DateImplement = DateTime.Now;
|
|
||||||
if (_orderStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
_logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus);
|
|
||||||
throw new ArgumentException($"Невозможно приствоить статус {requiredStatus} заказу с текущим статусом {model.Status}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\AbstractFoodOrdersDataModels\AbstractFoodOrdersDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,17 +0,0 @@
|
|||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class ComponentBindingModel : IComponentModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
|
||||||
public double Cost { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class DishBindingModel : IDishModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string DishName { get; set; } = string.Empty;
|
|
||||||
public double Price { get; set; }
|
|
||||||
public Dictionary<int, (IComponentModel, int)> DishComponents { get; set; } = new();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
using AbstractFoodOrdersDataModels.Enums;
|
|
||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class OrderBindingModel : IOrderModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int DishId { get; set; }
|
|
||||||
public int Count { get; set; }
|
|
||||||
public double Sum { get; set; }
|
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
|
||||||
public DateTime? DateImplement { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IComponentLogic
|
|
||||||
{
|
|
||||||
List<ComponentViewModel>? ReadList(ComponentSearchModel? model);
|
|
||||||
ComponentViewModel? ReadElement(ComponentSearchModel model);
|
|
||||||
bool Create(ComponentBindingModel model);
|
|
||||||
bool Update(ComponentBindingModel model);
|
|
||||||
bool Delete(ComponentBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IDishLogic
|
|
||||||
{
|
|
||||||
List<DishViewModel>? ReadList(DishSearchModel? model);
|
|
||||||
DishViewModel? ReadElement(DishSearchModel model);
|
|
||||||
bool Create(DishBindingModel model);
|
|
||||||
bool Update(DishBindingModel model);
|
|
||||||
bool Delete(DishBindingModel model);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersContracts.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,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersContracts.SearchModels
|
|
||||||
{
|
|
||||||
public class ComponentSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
public string? ComponentName { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersContracts.SearchModels
|
|
||||||
{
|
|
||||||
public class DishSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
public string? DishName { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersContracts.SearchModels
|
|
||||||
{
|
|
||||||
public class OrderSearchModel
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IComponentStorage
|
|
||||||
{
|
|
||||||
List<ComponentViewModel> GetFullList();
|
|
||||||
List<ComponentViewModel> GetFilteredList(ComponentSearchModel model);
|
|
||||||
ComponentViewModel? GetElement(ComponentSearchModel model);
|
|
||||||
ComponentViewModel? Insert(ComponentBindingModel model);
|
|
||||||
ComponentViewModel? Update(ComponentBindingModel model);
|
|
||||||
ComponentViewModel? Delete(ComponentBindingModel model);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IDishStorage
|
|
||||||
{
|
|
||||||
List<DishViewModel> GetFullList();
|
|
||||||
List<DishViewModel> GetFilteredList(DishSearchModel model);
|
|
||||||
DishViewModel? GetElement(DishSearchModel model);
|
|
||||||
DishViewModel? Insert(DishBindingModel model);
|
|
||||||
DishViewModel? Update(DishBindingModel model);
|
|
||||||
DishViewModel? Delete(DishBindingModel model);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersContracts.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,20 +0,0 @@
|
|||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class ComponentViewModel : IComponentModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
[DisplayName("Название компонента")]
|
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
|
||||||
[DisplayName("Цена")]
|
|
||||||
public double Cost { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class DishViewModel : IDishModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
[DisplayName("Название изделия")]
|
|
||||||
public string DishName { get; set; } = string.Empty;
|
|
||||||
[DisplayName("Цена")]
|
|
||||||
public double Price { get; set; }
|
|
||||||
public Dictionary<int, (IComponentModel, int)> DishComponents { get; set; } = new();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
using AbstractFoodOrdersDataModels.Enums;
|
|
||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class OrderViewModel : IOrderModel
|
|
||||||
{
|
|
||||||
[DisplayName("Номер")]
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int DishId { get; set; }
|
|
||||||
[DisplayName("Изделие")]
|
|
||||||
public string DishName { 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,14 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDataModels.Enums
|
|
||||||
{
|
|
||||||
public enum OrderStatus
|
|
||||||
{
|
|
||||||
Неизвестен = -1,
|
|
||||||
Принят = 0,
|
|
||||||
Выполняется = 1,
|
|
||||||
Готов = 2,
|
|
||||||
Выдан = 3
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDataModels
|
|
||||||
{
|
|
||||||
public interface IId
|
|
||||||
{
|
|
||||||
int Id { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDataModels.Models
|
|
||||||
{
|
|
||||||
public interface IComponentModel : IId
|
|
||||||
{
|
|
||||||
string ComponentName { get; }
|
|
||||||
double Cost { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDataModels.Models
|
|
||||||
{
|
|
||||||
public interface IDishModel : IId
|
|
||||||
{
|
|
||||||
string DishName { get; }
|
|
||||||
double Price { get; }
|
|
||||||
Dictionary<int, (IComponentModel, int)> DishComponents { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using AbstractFoodOrdersDataModels.Enums;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDataModels.Models
|
|
||||||
{
|
|
||||||
public interface IOrderModel : IId
|
|
||||||
{
|
|
||||||
int DishId { get; }
|
|
||||||
int Count { get; }
|
|
||||||
double Sum { get; }
|
|
||||||
OrderStatus Status { get; }
|
|
||||||
DateTime DateCreate { get; }
|
|
||||||
DateTime? DateImplement { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
using AbstractFoodOrdersDatabaseImplement.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDatabaseImplement
|
|
||||||
{
|
|
||||||
public class AbstractFoodOrdersDatabase : DbContext
|
|
||||||
{
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder
|
|
||||||
optionsBuilder)
|
|
||||||
{
|
|
||||||
if (optionsBuilder.IsConfigured == false)
|
|
||||||
{
|
|
||||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-7A1PHA0\SQLEXPRESS;
|
|
||||||
Initial Catalog=AbstractFoodOrdersDatabaseFull;
|
|
||||||
Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
|
||||||
}
|
|
||||||
base.OnConfiguring(optionsBuilder);
|
|
||||||
}
|
|
||||||
public virtual DbSet<Component> Components { set; get; }
|
|
||||||
public virtual DbSet<Dish> Dishes { set; get; }
|
|
||||||
public virtual DbSet<DishComponent> DishComponents { 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.4" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\AbstractFoodOrdersContracts\AbstractFoodOrdersContracts.csproj" />
|
|
||||||
<ProjectReference Include="..\AbstractFoodOrdersDataModels\AbstractFoodOrdersDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,89 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.StoragesContracts;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersDatabaseImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDatabaseImplement.Implements
|
|
||||||
{
|
|
||||||
public class ComponentStorage : IComponentStorage
|
|
||||||
{
|
|
||||||
public List<ComponentViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
return context.Components
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel
|
|
||||||
model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
return context.Components
|
|
||||||
.Where(x => x.ComponentName.Contains(model.ComponentName))
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
return context.Components
|
|
||||||
.FirstOrDefault(x =>
|
|
||||||
(!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName ==
|
|
||||||
model.ComponentName) ||
|
|
||||||
(model.Id.HasValue && x.Id == model.Id))
|
|
||||||
?.GetViewModel;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? Insert(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
var newComponent = Component.Create(model);
|
|
||||||
if (newComponent == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
context.Components.Add(newComponent);
|
|
||||||
context.SaveChanges();
|
|
||||||
return newComponent.GetViewModel;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
var component = context.Components.FirstOrDefault(x => x.Id ==
|
|
||||||
model.Id);
|
|
||||||
if (component == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
component.Update(model);
|
|
||||||
context.SaveChanges();
|
|
||||||
return component.GetViewModel;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
var element = context.Components.FirstOrDefault(rec => rec.Id ==
|
|
||||||
model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
context.Components.Remove(element);
|
|
||||||
context.SaveChanges();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,110 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.StoragesContracts;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersDatabaseImplement.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDatabaseImplement.Implements
|
|
||||||
{
|
|
||||||
public class DishStorage : IDishStorage
|
|
||||||
{
|
|
||||||
public List<DishViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
return context.Dishes
|
|
||||||
.Include(x => x.Components)
|
|
||||||
.ThenInclude(x => x.Component)
|
|
||||||
.ToList()
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
public List<DishViewModel> GetFilteredList(DishSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.DishName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
return context.Dishes
|
|
||||||
.Include(x => x.Components)
|
|
||||||
.ThenInclude(x => x.Component)
|
|
||||||
.Where(x => x.DishName.Contains(model.DishName))
|
|
||||||
.ToList()
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
public DishViewModel? GetElement(DishSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.DishName) &&
|
|
||||||
!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
return context.Dishes
|
|
||||||
.Include(x => x.Components)
|
|
||||||
.ThenInclude(x => x.Component)
|
|
||||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.DishName) &&
|
|
||||||
x.DishName == model.DishName) ||
|
|
||||||
(model.Id.HasValue && x.Id ==
|
|
||||||
model.Id))
|
|
||||||
?.GetViewModel;
|
|
||||||
}
|
|
||||||
public DishViewModel? Insert(DishBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
var newProduct = Dish.Create(context, model);
|
|
||||||
if (newProduct == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
context.Dishes.Add(newProduct);
|
|
||||||
context.SaveChanges();
|
|
||||||
return newProduct.GetViewModel;
|
|
||||||
}
|
|
||||||
public DishViewModel? Update(DishBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
using var transaction = context.Database.BeginTransaction();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var product = context.Dishes.FirstOrDefault(rec =>
|
|
||||||
rec.Id == model.Id);
|
|
||||||
if (product == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
product.Update(model);
|
|
||||||
context.SaveChanges();
|
|
||||||
product.UpdateComponents(context, model);
|
|
||||||
transaction.Commit();
|
|
||||||
return product.GetViewModel;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
transaction.Rollback();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public DishViewModel? Delete(DishBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
var element = context.Dishes
|
|
||||||
.Include(x => x.Components)
|
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
context.Dishes.Remove(element);
|
|
||||||
context.SaveChanges();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.StoragesContracts;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersDatabaseImplement.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDatabaseImplement.Implements
|
|
||||||
{
|
|
||||||
public class OrderStorage : IOrderStorage
|
|
||||||
{
|
|
||||||
public List<OrderViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
return context.Orders
|
|
||||||
.Select(x => AccessDishStorage(x.GetViewModel, context))
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
return context.Orders
|
|
||||||
.Where(x => x.Id == model.Id)
|
|
||||||
.Select(x => AccessDishStorage(x.GetViewModel, context))
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
return AccessDishStorage(context.Orders
|
|
||||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
|
||||||
?.GetViewModel, context);
|
|
||||||
}
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
var newOrder = Order.Create(model);
|
|
||||||
if (newOrder == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
context.Orders.Add(newOrder);
|
|
||||||
context.SaveChanges();
|
|
||||||
return AccessDishStorage(newOrder.GetViewModel, context);
|
|
||||||
}
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
|
||||||
if (order == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
order.Update(model);
|
|
||||||
context.SaveChanges();
|
|
||||||
return AccessDishStorage(order.GetViewModel, context);
|
|
||||||
}
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
using var context = new AbstractFoodOrdersDatabase();
|
|
||||||
var element = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
context.Orders.Remove(element);
|
|
||||||
context.SaveChanges();
|
|
||||||
return AccessDishStorage(element.GetViewModel, context);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
static OrderViewModel AccessDishStorage(OrderViewModel model, AbstractFoodOrdersDatabase context)
|
|
||||||
{
|
|
||||||
if (model == null) return model;
|
|
||||||
string? dishName = context.Dishes.FirstOrDefault(x => x.Id == model.DishId)?.DishName;
|
|
||||||
if (dishName != null) model.DishName = dishName;
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,171 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using AbstractFoodOrdersDatabaseImplement;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(AbstractFoodOrdersDatabase))]
|
|
||||||
[Migration("20230402145825_InitialCreate")]
|
|
||||||
partial class InitialCreate
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "7.0.4")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ComponentName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<double>("Cost")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Components");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.Dish", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("DishName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<double>("Price")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Dishes");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.DishComponent", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("ComponentId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("DishId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ComponentId");
|
|
||||||
|
|
||||||
b.HasIndex("DishId");
|
|
||||||
|
|
||||||
b.ToTable("DishComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("DateImplement")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<int>("DishId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<double>("Sum")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("DishId");
|
|
||||||
|
|
||||||
b.ToTable("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.DishComponent", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("AbstractFoodOrdersDatabaseImplement.Models.Component", "Component")
|
|
||||||
.WithMany("DishComponents")
|
|
||||||
.HasForeignKey("ComponentId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("AbstractFoodOrdersDatabaseImplement.Models.Dish", "Dish")
|
|
||||||
.WithMany("Components")
|
|
||||||
.HasForeignKey("DishId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Component");
|
|
||||||
|
|
||||||
b.Navigation("Dish");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("AbstractFoodOrdersDatabaseImplement.Models.Dish", "Dish")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("DishId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Dish");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("DishComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.Dish", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Components");
|
|
||||||
|
|
||||||
b.Navigation("Orders");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,125 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class InitialCreate : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Components",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Cost = table.Column<double>(type: "float", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Components", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Dishes",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
DishName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Price = table.Column<double>(type: "float", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Dishes", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "DishComponents",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
DishId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
ComponentId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Count = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_DishComponents", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_DishComponents_Components_ComponentId",
|
|
||||||
column: x => x.ComponentId,
|
|
||||||
principalTable: "Components",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_DishComponents_Dishes_DishId",
|
|
||||||
column: x => x.DishId,
|
|
||||||
principalTable: "Dishes",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Orders",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
DishId = 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_Dishes_DishId",
|
|
||||||
column: x => x.DishId,
|
|
||||||
principalTable: "Dishes",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_DishComponents_ComponentId",
|
|
||||||
table: "DishComponents",
|
|
||||||
column: "ComponentId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_DishComponents_DishId",
|
|
||||||
table: "DishComponents",
|
|
||||||
column: "DishId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_DishId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "DishId");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "DishComponents");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Orders");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Components");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Dishes");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,168 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using AbstractFoodOrdersDatabaseImplement;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(AbstractFoodOrdersDatabase))]
|
|
||||||
partial class AbstractFoodOrdersDatabaseModelSnapshot : ModelSnapshot
|
|
||||||
{
|
|
||||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "7.0.4")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ComponentName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<double>("Cost")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Components");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.Dish", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("DishName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<double>("Price")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Dishes");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.DishComponent", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("ComponentId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("DishId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ComponentId");
|
|
||||||
|
|
||||||
b.HasIndex("DishId");
|
|
||||||
|
|
||||||
b.ToTable("DishComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("DateImplement")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<int>("DishId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<double>("Sum")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("DishId");
|
|
||||||
|
|
||||||
b.ToTable("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.DishComponent", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("AbstractFoodOrdersDatabaseImplement.Models.Component", "Component")
|
|
||||||
.WithMany("DishComponents")
|
|
||||||
.HasForeignKey("ComponentId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("AbstractFoodOrdersDatabaseImplement.Models.Dish", "Dish")
|
|
||||||
.WithMany("Components")
|
|
||||||
.HasForeignKey("DishId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Component");
|
|
||||||
|
|
||||||
b.Navigation("Dish");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("AbstractFoodOrdersDatabaseImplement.Models.Dish", "Dish")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("DishId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Dish");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("DishComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AbstractFoodOrdersDatabaseImplement.Models.Dish", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Components");
|
|
||||||
|
|
||||||
b.Navigation("Orders");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class Component : IComponentModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
[Required]
|
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
|
||||||
[Required]
|
|
||||||
public double Cost { get; set; }
|
|
||||||
[ForeignKey("ComponentId")]
|
|
||||||
public virtual List<DishComponent> DishComponents { get; set; } = new();
|
|
||||||
public static Component? Create(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Component()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
ComponentName = model.ComponentName,
|
|
||||||
Cost = model.Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public static Component Create(ComponentViewModel model)
|
|
||||||
{
|
|
||||||
return new Component
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
ComponentName = model.ComponentName,
|
|
||||||
Cost = model.Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ComponentName = model.ComponentName;
|
|
||||||
Cost = model.Cost;
|
|
||||||
}
|
|
||||||
public ComponentViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
ComponentName = ComponentName,
|
|
||||||
Cost = Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,101 +0,0 @@
|
|||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class Dish : IDishModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
[Required]
|
|
||||||
public string DishName { get; set; } = string.Empty;
|
|
||||||
[Required]
|
|
||||||
public double Price { get; set; }
|
|
||||||
private Dictionary<int, (IComponentModel, int)>? _dishComponents = null;
|
|
||||||
[NotMapped]
|
|
||||||
public Dictionary<int, (IComponentModel, int)> DishComponents
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_dishComponents == null)
|
|
||||||
{
|
|
||||||
_dishComponents = Components
|
|
||||||
.ToDictionary(recPC => recPC.ComponentId, recPC =>
|
|
||||||
(recPC.Component as IComponentModel, recPC.Count));
|
|
||||||
}
|
|
||||||
return _dishComponents;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[ForeignKey("DishId")]
|
|
||||||
public virtual List<DishComponent> Components { get; set; } = new();
|
|
||||||
[ForeignKey("DishId")]
|
|
||||||
public virtual List<Order> Orders { get; set; } = new();
|
|
||||||
public static Dish Create(AbstractFoodOrdersDatabase context,
|
|
||||||
DishBindingModel model)
|
|
||||||
{
|
|
||||||
return new Dish()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
DishName = model.DishName,
|
|
||||||
Price = model.Price,
|
|
||||||
Components = model.DishComponents.Select(x => new
|
|
||||||
DishComponent
|
|
||||||
{
|
|
||||||
Component = context.Components.First(y => y.Id == x.Key),
|
|
||||||
Count = x.Value.Item2
|
|
||||||
}).ToList()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(DishBindingModel model)
|
|
||||||
{
|
|
||||||
DishName = model.DishName;
|
|
||||||
Price = model.Price;
|
|
||||||
}
|
|
||||||
public DishViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
DishName = DishName,
|
|
||||||
Price = Price,
|
|
||||||
DishComponents = DishComponents
|
|
||||||
};
|
|
||||||
public void UpdateComponents(AbstractFoodOrdersDatabase context,
|
|
||||||
DishBindingModel model)
|
|
||||||
{
|
|
||||||
var dishComponents = context.DishComponents.Where(rec =>
|
|
||||||
rec.DishId == model.Id).ToList();
|
|
||||||
if (dishComponents != null && dishComponents.Count > 0)
|
|
||||||
{ // удалили те, которых нет в модели
|
|
||||||
context.DishComponents.RemoveRange(dishComponents.Where(rec
|
|
||||||
=> !model.DishComponents.ContainsKey(rec.ComponentId)));
|
|
||||||
context.SaveChanges();
|
|
||||||
// обновили количество у существующих записей
|
|
||||||
foreach (var updateComponent in dishComponents)
|
|
||||||
{
|
|
||||||
updateComponent.Count =
|
|
||||||
model.DishComponents[updateComponent.ComponentId].Item2;
|
|
||||||
model.DishComponents.Remove(updateComponent.ComponentId);
|
|
||||||
}
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
var dish = context.Dishes.First(x => x.Id == Id);
|
|
||||||
foreach (var pc in model.DishComponents)
|
|
||||||
{
|
|
||||||
context.DishComponents.Add(new DishComponent
|
|
||||||
{
|
|
||||||
Dish = dish,
|
|
||||||
Component = context.Components.First(x => x.Id == pc.Key),
|
|
||||||
Count = pc.Value.Item2
|
|
||||||
});
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
|
||||||
_dishComponents = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class DishComponent
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
[Required]
|
|
||||||
public int DishId { get; set; }
|
|
||||||
[Required]
|
|
||||||
public int ComponentId { get; set; }
|
|
||||||
[Required]
|
|
||||||
public int Count { get; set; }
|
|
||||||
public virtual Component Component { get; set; } = new();
|
|
||||||
public virtual Dish Dish { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersDataModels.Enums;
|
|
||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersDatabaseImplement.Models
|
|
||||||
{
|
|
||||||
public class Order : IOrderModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
[Required]
|
|
||||||
public int DishId { get; private set; }
|
|
||||||
[Required]
|
|
||||||
public int Count { get; private set; }
|
|
||||||
[Required]
|
|
||||||
public double Sum { get; private set; }
|
|
||||||
[Required]
|
|
||||||
public OrderStatus Status { get; private set; }
|
|
||||||
[Required]
|
|
||||||
public DateTime DateCreate { get; private set; }
|
|
||||||
public DateTime? DateImplement { get; private set; }
|
|
||||||
public virtual Dish Dish { get; set; }
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Order()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
DishId = model.DishId,
|
|
||||||
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;
|
|
||||||
if (model.DateImplement.HasValue) DateImplement = model.DateImplement;
|
|
||||||
}
|
|
||||||
public OrderViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
DishId = DishId,
|
|
||||||
Count = Count,
|
|
||||||
Sum = Sum,
|
|
||||||
Status = Status,
|
|
||||||
DateCreate = DateCreate,
|
|
||||||
DateImplement = DateImplement
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\AbstractFoodOrdersContracts\AbstractFoodOrdersContracts.csproj" />
|
|
||||||
<ProjectReference Include="..\AbstractFoodOrdersDataModels\AbstractFoodOrdersDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,31 +0,0 @@
|
|||||||
using AbstractFoodOrdersListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersListImplement
|
|
||||||
{
|
|
||||||
public class DataListSingleton
|
|
||||||
{
|
|
||||||
private static DataListSingleton? _instance;
|
|
||||||
public List<Component> Components { get; set; }
|
|
||||||
public List<Order> Orders { get; set; }
|
|
||||||
public List<Dish> Dishes { get; set; }
|
|
||||||
private DataListSingleton()
|
|
||||||
{
|
|
||||||
Components = new List<Component>();
|
|
||||||
Orders = new List<Order>();
|
|
||||||
Dishes = new List<Dish>();
|
|
||||||
}
|
|
||||||
public static DataListSingleton GetInstance()
|
|
||||||
{
|
|
||||||
if (_instance == null)
|
|
||||||
{
|
|
||||||
_instance = new DataListSingleton();
|
|
||||||
}
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,111 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.StoragesContracts;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersListImplement.Implements
|
|
||||||
{
|
|
||||||
public class ComponentStorage : IComponentStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
public ComponentStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
public List<ComponentViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<ComponentViewModel>();
|
|
||||||
foreach (var ingredient in _source.Components)
|
|
||||||
{
|
|
||||||
result.Add(ingredient.GetViewModel);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<ComponentViewModel>();
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
foreach (var ingredient in _source.Components)
|
|
||||||
{
|
|
||||||
if (ingredient.ComponentName.Contains(model.ComponentName))
|
|
||||||
{
|
|
||||||
result.Add(ingredient.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var ingredient in _source.Components)
|
|
||||||
{
|
|
||||||
if ((!string.IsNullOrEmpty(model.ComponentName) && ingredient.ComponentName == model.ComponentName) ||
|
|
||||||
(model.Id.HasValue && ingredient.Id == model.Id))
|
|
||||||
{
|
|
||||||
return ingredient.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? Insert(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
foreach (var ingredient in _source.Components)
|
|
||||||
{
|
|
||||||
if (model.Id <= ingredient.Id)
|
|
||||||
{
|
|
||||||
model.Id = ingredient.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var newIngredient = Component.Create(model);
|
|
||||||
if (newIngredient == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_source.Components.Add(newIngredient);
|
|
||||||
return newIngredient.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var ingredient in _source.Components)
|
|
||||||
{
|
|
||||||
if (ingredient.Id == model.Id)
|
|
||||||
{
|
|
||||||
ingredient.Update(model);
|
|
||||||
return ingredient.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Components.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Components[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Components[i];
|
|
||||||
_source.Components.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,106 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.StoragesContracts;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersListImplement.Implements
|
|
||||||
{
|
|
||||||
public class DishStorage : IDishStorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
public DishStorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
public List<DishViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<DishViewModel>();
|
|
||||||
foreach (var dish in _source.Dishes)
|
|
||||||
{
|
|
||||||
result.Add(dish.GetViewModel);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public List<DishViewModel> GetFilteredList(DishSearchModel model)
|
|
||||||
{
|
|
||||||
var result = new List<DishViewModel>();
|
|
||||||
if (string.IsNullOrEmpty(model.DishName))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
foreach (var dish in _source.Dishes)
|
|
||||||
{
|
|
||||||
if (dish.DishName.Contains(model.DishName))
|
|
||||||
{
|
|
||||||
result.Add(dish.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public DishViewModel? GetElement(DishSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.DishName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var dish in _source.Dishes)
|
|
||||||
{
|
|
||||||
if ((!string.IsNullOrEmpty(model.DishName) && dish.DishName == model.DishName) ||
|
|
||||||
(model.Id.HasValue && dish.Id == model.Id))
|
|
||||||
{
|
|
||||||
return dish.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public DishViewModel? Insert(DishBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
foreach (var dish in _source.Dishes)
|
|
||||||
{
|
|
||||||
if (model.Id <= dish.Id)
|
|
||||||
{
|
|
||||||
model.Id = dish.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var newDish = Dish.Create(model);
|
|
||||||
if (newDish == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_source.Dishes.Add(newDish);
|
|
||||||
return newDish.GetViewModel;
|
|
||||||
}
|
|
||||||
public DishViewModel? Update(DishBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var dish in _source.Dishes)
|
|
||||||
{
|
|
||||||
if (dish.Id == model.Id)
|
|
||||||
{
|
|
||||||
dish.Update(model);
|
|
||||||
return dish.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public DishViewModel? Delete(DishBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.Dishes.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.Dishes[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.Dishes[i];
|
|
||||||
_source.Dishes.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,123 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.StoragesContracts;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersListImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersListImplement.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(AttachReinforcedName(order.GetViewModel));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
//А, собственно, этт метод не имеет ценности, так как повторяет функционал следующего
|
|
||||||
var result = new List<OrderViewModel>();
|
|
||||||
if (model == null || !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (order.Id == model.Id)
|
|
||||||
{
|
|
||||||
result.Add(AttachReinforcedName(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 AttachReinforcedName(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 AttachReinforcedName(newOrder.GetViewModel);
|
|
||||||
}
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var order in _source.Orders)
|
|
||||||
{
|
|
||||||
if (order.Id == model.Id)
|
|
||||||
{
|
|
||||||
order.Update(model);
|
|
||||||
return AttachReinforcedName(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 AttachReinforcedName(element.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
private OrderViewModel AttachReinforcedName(OrderViewModel model)
|
|
||||||
{
|
|
||||||
//Из всех мест, это выглядит наиболее подходящим, для данной манипуляции.
|
|
||||||
//При расположении ниже нарушится целостность данных
|
|
||||||
//При расположении выше будет нарушен принцип разделения уровней
|
|
||||||
foreach (var reinforced in _source.Dishes)
|
|
||||||
{
|
|
||||||
if (reinforced.Id == model.DishId)
|
|
||||||
{
|
|
||||||
model.DishName = reinforced.DishName;
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersListImplement.Models
|
|
||||||
{
|
|
||||||
public class Component : IComponentModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
|
||||||
public double Cost { get; set; }
|
|
||||||
public static Component? Create(ComponentBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Component()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
ComponentName = model.ComponentName,
|
|
||||||
Cost = model.Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(ComponentBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ComponentName = model.ComponentName;
|
|
||||||
Cost = model.Cost;
|
|
||||||
}
|
|
||||||
public ComponentViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
ComponentName = ComponentName,
|
|
||||||
Cost = Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersListImplement.Models
|
|
||||||
{
|
|
||||||
public class Dish : IDishModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string DishName { get; private set; } = string.Empty;
|
|
||||||
public double Price { get; private set; }
|
|
||||||
public Dictionary<int, (IComponentModel, int)> DishComponents
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
private set;
|
|
||||||
} = new Dictionary<int, (IComponentModel, int)>();
|
|
||||||
public static Dish? Create(DishBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Dish(){ Id = model.Id, DishName = model.DishName, Price = model.Price, DishComponents = model.DishComponents };
|
|
||||||
}
|
|
||||||
public void Update(DishBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DishName = model.DishName;
|
|
||||||
Price = model.Price;
|
|
||||||
DishComponents = model.DishComponents;
|
|
||||||
}
|
|
||||||
public DishViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
DishName = DishName,
|
|
||||||
Price = Price,
|
|
||||||
DishComponents = DishComponents
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersDataModels.Enums;
|
|
||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersListImplement.Models
|
|
||||||
{
|
|
||||||
public class Order : IOrderModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public int DishId { 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,
|
|
||||||
DishId = model.DishId,
|
|
||||||
Count = model.Count,
|
|
||||||
Sum = model.Sum,
|
|
||||||
Status = model.Status,
|
|
||||||
DateCreate = model.DateCreate,
|
|
||||||
DateImplement = model.DateImplement,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(OrderBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DishId = model.DishId;
|
|
||||||
Count = model.Count;
|
|
||||||
Sum = model.Sum;
|
|
||||||
Status = model.Status;
|
|
||||||
DateCreate = model.DateCreate;
|
|
||||||
DateImplement = model.DateImplement;
|
|
||||||
}
|
|
||||||
public OrderViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
DishId = DishId,
|
|
||||||
Count = Count,
|
|
||||||
Sum = Sum,
|
|
||||||
Status = Status,
|
|
||||||
DateCreate = DateCreate,
|
|
||||||
DateImplement = DateImplement,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\AbstractFoodOrdersContracts\AbstractFoodOrdersContracts.csproj" />
|
|
||||||
<ProjectReference Include="..\AbstractFoodOrdersDataModels\AbstractFoodOrdersDataModels.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,63 +0,0 @@
|
|||||||
using AbstractFoodOrdersFileImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersFileImplement
|
|
||||||
{
|
|
||||||
internal class DataFileSingleton
|
|
||||||
{
|
|
||||||
private static DataFileSingleton? instance;
|
|
||||||
private readonly string ComponentFileName = "Component.xml";
|
|
||||||
private readonly string OrderFileName = "Order.xml";
|
|
||||||
private readonly string DishFileName = "Dish.xml";
|
|
||||||
public List<Component> Components { get; private set; }
|
|
||||||
public List<Order> Orders { get; private set; }
|
|
||||||
public List<Dish> Dishes { get; private set; }
|
|
||||||
public static DataFileSingleton GetInstance()
|
|
||||||
{
|
|
||||||
if (instance == null)
|
|
||||||
{
|
|
||||||
instance = new DataFileSingleton();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
public void SaveComponents() => SaveData(Components, ComponentFileName,
|
|
||||||
"Components", x => x.GetXElement);
|
|
||||||
public void SaveDishes() => SaveData(Dishes, DishFileName,
|
|
||||||
"Dishes", x => x.GetXElement);
|
|
||||||
public void SaveOrders() => SaveData(Orders, OrderFileName,
|
|
||||||
"Orders", x => x.GetXElement);
|
|
||||||
private DataFileSingleton()
|
|
||||||
{
|
|
||||||
Components = LoadData(ComponentFileName, "Component", x =>
|
|
||||||
Component.Create(x)!)!;
|
|
||||||
Dishes = LoadData(DishFileName, "Dish", x =>
|
|
||||||
Dish.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,81 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.StoragesContracts;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersFileImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersFileImplement.Implements
|
|
||||||
{
|
|
||||||
public class ComponentStorage : IComponentStorage
|
|
||||||
{
|
|
||||||
private readonly DataFileSingleton source;
|
|
||||||
public ComponentStorage()
|
|
||||||
{
|
|
||||||
source = DataFileSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
public List<ComponentViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
return source.Components.Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel
|
|
||||||
model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
return source.Components.Where(x => x.ComponentName.Contains(model.ComponentName)).Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return source.Components.FirstOrDefault(x =>(!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) ||
|
|
||||||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? Insert(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = source.Components.Count > 0 ? source.Components.Max(x =>
|
|
||||||
x.Id) + 1 : 1;
|
|
||||||
var newComponent = Component.Create(model);
|
|
||||||
if (newComponent == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
source.Components.Add(newComponent);
|
|
||||||
source.SaveComponents();
|
|
||||||
return newComponent.GetViewModel;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
var component = source.Components.FirstOrDefault(x => x.Id ==
|
|
||||||
model.Id);
|
|
||||||
if (component == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
component.Update(model);
|
|
||||||
source.SaveComponents();
|
|
||||||
return component.GetViewModel;
|
|
||||||
}
|
|
||||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
var element = source.Components.FirstOrDefault(x => x.Id ==
|
|
||||||
model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
source.Components.Remove(element);
|
|
||||||
source.SaveComponents();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.StoragesContracts;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersFileImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersFileImplement.Implements
|
|
||||||
{
|
|
||||||
public class DishStorage : IDishStorage
|
|
||||||
{
|
|
||||||
private readonly DataFileSingleton source;
|
|
||||||
public DishStorage()
|
|
||||||
{
|
|
||||||
source = DataFileSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
public DishViewModel? Delete(DishBindingModel model)
|
|
||||||
{
|
|
||||||
var element = source.Dishes.FirstOrDefault(x => x.Id ==
|
|
||||||
model.Id);
|
|
||||||
if (element != null)
|
|
||||||
{
|
|
||||||
source.Dishes.Remove(element);
|
|
||||||
source.SaveDishes();
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DishViewModel? GetElement(DishSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.DishName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return source.Dishes.FirstOrDefault(x =>(!string.IsNullOrEmpty(model.DishName) && x.DishName ==model.DishName) ||
|
|
||||||
(model.Id.HasValue && x.Id == model.Id))
|
|
||||||
?.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DishViewModel> GetFilteredList(DishSearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.DishName))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
return source.Dishes.Where(x => x.DishName.Contains(model.DishName)).Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DishViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
return source.Dishes.Select(x => x.GetViewModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public DishViewModel? Insert(DishBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = source.Dishes.Count > 0 ? source.Dishes.Max(x =>
|
|
||||||
x.Id) + 1 : 1;
|
|
||||||
var newComponent = Dish.Create(model);
|
|
||||||
if (newComponent == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
source.Dishes.Add(newComponent);
|
|
||||||
source.SaveDishes();
|
|
||||||
return newComponent.GetViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DishViewModel? Update(DishBindingModel model)
|
|
||||||
{
|
|
||||||
var component = source.Dishes.FirstOrDefault(x => x.Id ==
|
|
||||||
model.Id);
|
|
||||||
if (component == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
component.Update(model);
|
|
||||||
source.SaveDishes();
|
|
||||||
return component.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,110 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.StoragesContracts;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersFileImplement.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersFileImplement.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 == 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;
|
|
||||||
|
|
||||||
var manufacture = source.Dishes.FirstOrDefault(x => x.Id == order.DishId);
|
|
||||||
|
|
||||||
if (manufacture != null)
|
|
||||||
{
|
|
||||||
viewModel.DishName = manufacture.DishName;
|
|
||||||
}
|
|
||||||
|
|
||||||
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,60 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersFileImplement.Models
|
|
||||||
{
|
|
||||||
public class Component : IComponentModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
|
||||||
public double Cost { get; set; }
|
|
||||||
public static Component? Create(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Component()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
ComponentName = model.ComponentName,
|
|
||||||
Cost = model.Cost
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public static Component? Create(XElement element)
|
|
||||||
{
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Component()
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
||||||
ComponentName = element.Element("ComponentName")!.Value,
|
|
||||||
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ComponentName = model.ComponentName;
|
|
||||||
Cost = model.Cost;
|
|
||||||
}
|
|
||||||
public ComponentViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
ComponentName = ComponentName,
|
|
||||||
Cost = Cost
|
|
||||||
};
|
|
||||||
public XElement GetXElement => new("Component",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("ComponentName", ComponentName),
|
|
||||||
new XElement("Cost", Cost.ToString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,100 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersFileImplement.Models
|
|
||||||
{
|
|
||||||
public class Dish : IDishModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string DishName { get; private set; } = string.Empty;
|
|
||||||
public double Price { get; private set; }
|
|
||||||
public Dictionary<int, int> Components { get; private set; } = new();
|
|
||||||
private Dictionary<int, (IComponentModel, int)>? _dishComponents =
|
|
||||||
null;
|
|
||||||
public Dictionary<int, (IComponentModel, int)> DishComponents
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_dishComponents == null)
|
|
||||||
{
|
|
||||||
var source = DataFileSingleton.GetInstance();
|
|
||||||
_dishComponents = Components.ToDictionary(x => x.Key, y =>
|
|
||||||
((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!,
|
|
||||||
y.Value));
|
|
||||||
}
|
|
||||||
return _dishComponents;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static Dish? Create(DishBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Dish()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
DishName = model.DishName,
|
|
||||||
Price = model.Price,
|
|
||||||
Components = model.DishComponents.ToDictionary(x => x.Key, x
|
|
||||||
=> x.Value.Item2)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public static Dish? Create(XElement element)
|
|
||||||
{
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new Dish()
|
|
||||||
{
|
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
|
||||||
DishName = element.Element("DishName")!.Value,
|
|
||||||
Price = Convert.ToDouble(element.Element("Price")!.Value),
|
|
||||||
Components =
|
|
||||||
element.Element("DishComponents")!.Elements("DishComponent")
|
|
||||||
.ToDictionary(x =>
|
|
||||||
Convert.ToInt32(x.Element("Key")?.Value), x =>
|
|
||||||
Convert.ToInt32(x.Element("Value")?.Value))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(DishBindingModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DishName = model.DishName;
|
|
||||||
Price = model.Price;
|
|
||||||
Components = model.DishComponents.ToDictionary(x => x.Key, x =>
|
|
||||||
x.Value.Item2);
|
|
||||||
_dishComponents = null;
|
|
||||||
}
|
|
||||||
public DishViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
DishName = DishName,
|
|
||||||
Price = Price,
|
|
||||||
DishComponents = DishComponents
|
|
||||||
};
|
|
||||||
public XElement GetXElement => new("Dish",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("DishName", DishName),
|
|
||||||
new XElement("Price", Price.ToString()),
|
|
||||||
new XElement("DishComponents", Components.Select(x =>
|
|
||||||
new XElement("DishComponent",
|
|
||||||
|
|
||||||
new XElement("Key", x.Key),
|
|
||||||
|
|
||||||
new XElement("Value", x.Value)))
|
|
||||||
|
|
||||||
.ToArray()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,92 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersDataModels.Enums;
|
|
||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace AbstractFoodOrdersFileImplement.Models
|
|
||||||
{
|
|
||||||
public class Order : IOrderModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public int DishId { 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,
|
|
||||||
DishId = model.DishId,
|
|
||||||
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),
|
|
||||||
DishId = Convert.ToInt32(element.Element("DishId")!.Value),
|
|
||||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
|
||||||
Sum = Convert.ToDouble(element.Element("Sum")!.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;
|
|
||||||
}
|
|
||||||
DishId = model.DishId;
|
|
||||||
Count = model.Count;
|
|
||||||
Sum = model.Sum;
|
|
||||||
Status = model.Status;
|
|
||||||
DateCreate = model.DateCreate;
|
|
||||||
DateImplement = model.DateImplement;
|
|
||||||
}
|
|
||||||
public OrderViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
DishId = DishId,
|
|
||||||
Count = Count,
|
|
||||||
Sum = Sum,
|
|
||||||
Status = Status,
|
|
||||||
DateCreate = DateCreate,
|
|
||||||
DateImplement = DateImplement,
|
|
||||||
};
|
|
||||||
public XElement GetXElement => new("Order",
|
|
||||||
new XAttribute("Id", Id),
|
|
||||||
new XElement("DishId", DishId),
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,19 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.3.32901.215
|
VisualStudioVersion = 17.3.32901.215
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FoodOrders", "FoodOrders\FoodOrders.csproj", "{4DC7A9CF-C994-4010-B23B-F4DB4D964D1D}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FoodOrders", "FoodOrders\FoodOrders.csproj", "{4DC7A9CF-C994-4010-B23B-F4DB4D964D1D}"
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractFoodOrdersDataModels", "AbstractFoodOrdersDataModels\AbstractFoodOrdersDataModels.csproj", "{797093A6-6C7B-414E-874F-1BB48A6468C7}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractFoodOrdersContracts", "AbstractFoodOrdersContracts\AbstractFoodOrdersContracts.csproj", "{926B4BA4-42BC-4D7B-AF27-01B16493D883}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractFoodOrdersBusinessLogic", "AbstractFoodOrdersBusinessLogic\AbstractFoodOrdersBusinessLogic.csproj", "{A595D2B1-2193-4688-BECD-6D815AEE1142}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractFoodOrdersListImplement", "AbstractFoodOrdersListImplement\AbstractFoodOrdersListImplement.csproj", "{275ED134-536F-4025-BE10-2718F66FBD10}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractFoodOrdersFileImplement", "AbstractShopFileImplement\AbstractFoodOrdersFileImplement.csproj", "{D0FC0C67-FFF7-4D2A-9194-A1466C82EDAB}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractFoodOrdersDatabaseImplement", "AbstractFoodOrdersDatabaseImplement\AbstractFoodOrdersDatabaseImplement.csproj", "{E6FA5D86-8EBB-46C7-93D5-CE9FFC7A3566}"
|
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -27,30 +15,6 @@ Global
|
|||||||
{4DC7A9CF-C994-4010-B23B-F4DB4D964D1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{4DC7A9CF-C994-4010-B23B-F4DB4D964D1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{4DC7A9CF-C994-4010-B23B-F4DB4D964D1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{4DC7A9CF-C994-4010-B23B-F4DB4D964D1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{4DC7A9CF-C994-4010-B23B-F4DB4D964D1D}.Release|Any CPU.Build.0 = Release|Any CPU
|
{4DC7A9CF-C994-4010-B23B-F4DB4D964D1D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{797093A6-6C7B-414E-874F-1BB48A6468C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{797093A6-6C7B-414E-874F-1BB48A6468C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{797093A6-6C7B-414E-874F-1BB48A6468C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{797093A6-6C7B-414E-874F-1BB48A6468C7}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{926B4BA4-42BC-4D7B-AF27-01B16493D883}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{926B4BA4-42BC-4D7B-AF27-01B16493D883}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{926B4BA4-42BC-4D7B-AF27-01B16493D883}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{926B4BA4-42BC-4D7B-AF27-01B16493D883}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{A595D2B1-2193-4688-BECD-6D815AEE1142}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{A595D2B1-2193-4688-BECD-6D815AEE1142}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{A595D2B1-2193-4688-BECD-6D815AEE1142}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{A595D2B1-2193-4688-BECD-6D815AEE1142}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{275ED134-536F-4025-BE10-2718F66FBD10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{275ED134-536F-4025-BE10-2718F66FBD10}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{275ED134-536F-4025-BE10-2718F66FBD10}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{275ED134-536F-4025-BE10-2718F66FBD10}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{D0FC0C67-FFF7-4D2A-9194-A1466C82EDAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{D0FC0C67-FFF7-4D2A-9194-A1466C82EDAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{D0FC0C67-FFF7-4D2A-9194-A1466C82EDAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{D0FC0C67-FFF7-4D2A-9194-A1466C82EDAB}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{E6FA5D86-8EBB-46C7-93D5-CE9FFC7A3566}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{E6FA5D86-8EBB-46C7-93D5-CE9FFC7A3566}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{E6FA5D86-8EBB-46C7-93D5-CE9FFC7A3566}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{E6FA5D86-8EBB-46C7-93D5-CE9FFC7A3566}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -8,31 +8,4 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\AbstractFoodOrdersBusinessLogic\AbstractFoodOrdersBusinessLogic.csproj" />
|
|
||||||
<ProjectReference Include="..\AbstractFoodOrdersContracts\AbstractFoodOrdersContracts.csproj" />
|
|
||||||
<ProjectReference Include="..\AbstractFoodOrdersDatabaseImplement\AbstractFoodOrdersDatabaseImplement.csproj" />
|
|
||||||
<ProjectReference Include="..\AbstractFoodOrdersDataModels\AbstractFoodOrdersDataModels.csproj" />
|
|
||||||
<ProjectReference Include="..\AbstractFoodOrdersListImplement\AbstractFoodOrdersListImplement.csproj" />
|
|
||||||
<ProjectReference Include="..\AbstractShopFileImplement\AbstractFoodOrdersFileImplement.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="FormComponent.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="FormComponents.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
39
FoodOrders/FoodOrders/Form1.Designer.cs
generated
Normal file
39
FoodOrders/FoodOrders/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace FoodOrders
|
||||||
|
{
|
||||||
|
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
FoodOrders/FoodOrders/Form1.cs
Normal file
10
FoodOrders/FoodOrders/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace FoodOrders
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
FoodOrders/FoodOrders/Form1.resx
Normal file
120
FoodOrders/FoodOrders/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>
|
118
FoodOrders/FoodOrders/FormComponent.Designer.cs
generated
118
FoodOrders/FoodOrders/FormComponent.Designer.cs
generated
@ -1,118 +0,0 @@
|
|||||||
namespace FoodOrders
|
|
||||||
{
|
|
||||||
partial class FormComponent
|
|
||||||
{
|
|
||||||
/// <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.labelName = new System.Windows.Forms.Label();
|
|
||||||
this.labelCost = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
|
||||||
this.textBoxCost = new System.Windows.Forms.TextBox();
|
|
||||||
this.ButtonSave = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
this.labelName.AutoSize = true;
|
|
||||||
this.labelName.Location = new System.Drawing.Point(28, 70);
|
|
||||||
this.labelName.Name = "labelName";
|
|
||||||
this.labelName.Size = new System.Drawing.Size(80, 20);
|
|
||||||
this.labelName.TabIndex = 0;
|
|
||||||
this.labelName.Text = "Название:";
|
|
||||||
//
|
|
||||||
// labelCost
|
|
||||||
//
|
|
||||||
this.labelCost.AutoSize = true;
|
|
||||||
this.labelCost.Location = new System.Drawing.Point(28, 113);
|
|
||||||
this.labelCost.Name = "labelCost";
|
|
||||||
this.labelCost.Size = new System.Drawing.Size(48, 20);
|
|
||||||
this.labelCost.TabIndex = 1;
|
|
||||||
this.labelCost.Text = "Цена:";
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
this.textBoxName.Location = new System.Drawing.Point(130, 63);
|
|
||||||
this.textBoxName.Name = "textBoxName";
|
|
||||||
this.textBoxName.Size = new System.Drawing.Size(274, 27);
|
|
||||||
this.textBoxName.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// textBoxCost
|
|
||||||
//
|
|
||||||
this.textBoxCost.Location = new System.Drawing.Point(130, 106);
|
|
||||||
this.textBoxCost.Name = "textBoxCost";
|
|
||||||
this.textBoxCost.Size = new System.Drawing.Size(171, 27);
|
|
||||||
this.textBoxCost.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// ButtonSave
|
|
||||||
//
|
|
||||||
this.ButtonSave.Location = new System.Drawing.Point(196, 169);
|
|
||||||
this.ButtonSave.Name = "ButtonSave";
|
|
||||||
this.ButtonSave.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.ButtonSave.TabIndex = 4;
|
|
||||||
this.ButtonSave.Text = "Сохранить";
|
|
||||||
this.ButtonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// ButtonCancel
|
|
||||||
//
|
|
||||||
this.ButtonCancel.Location = new System.Drawing.Point(310, 169);
|
|
||||||
this.ButtonCancel.Name = "ButtonCancel";
|
|
||||||
this.ButtonCancel.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.ButtonCancel.TabIndex = 5;
|
|
||||||
this.ButtonCancel.Text = "Отмена";
|
|
||||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// FormComponent
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(435, 222);
|
|
||||||
this.Controls.Add(this.ButtonCancel);
|
|
||||||
this.Controls.Add(this.ButtonSave);
|
|
||||||
this.Controls.Add(this.textBoxCost);
|
|
||||||
this.Controls.Add(this.textBoxName);
|
|
||||||
this.Controls.Add(this.labelCost);
|
|
||||||
this.Controls.Add(this.labelName);
|
|
||||||
this.Name = "FormComponent";
|
|
||||||
this.Text = "Компонент ";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label labelName;
|
|
||||||
private Label labelCost;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private TextBox textBoxCost;
|
|
||||||
private Button ButtonSave;
|
|
||||||
private Button ButtonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,97 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace FoodOrders
|
|
||||||
{
|
|
||||||
public partial class FormComponent : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IComponentLogic _logic;
|
|
||||||
private int? _id;
|
|
||||||
public int Id { set { _id = value; } }
|
|
||||||
public FormComponent(ILogger<FormComponent> logger, IComponentLogic
|
|
||||||
logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
private void FormComponent_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_id.HasValue)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение компонента");
|
|
||||||
var view = _logic.ReadElement(new ComponentSearchModel
|
|
||||||
{
|
|
||||||
Id =
|
|
||||||
_id.Value
|
|
||||||
});
|
|
||||||
if (view != null)
|
|
||||||
{
|
|
||||||
textBoxName.Text = view.ComponentName;
|
|
||||||
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 ComponentBindingModel
|
|
||||||
{
|
|
||||||
Id = _id ?? 0,
|
|
||||||
ComponentName = 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>
|
|
116
FoodOrders/FoodOrders/FormComponents.Designer.cs
generated
116
FoodOrders/FoodOrders/FormComponents.Designer.cs
generated
@ -1,116 +0,0 @@
|
|||||||
namespace FoodOrders
|
|
||||||
{
|
|
||||||
partial class FormComponents
|
|
||||||
{
|
|
||||||
/// <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.ButtonAdd = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonRef = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonDel = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonUpd = new System.Windows.Forms.Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(1, 1);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(508, 448);
|
|
||||||
this.dataGridView.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// ButtonAdd
|
|
||||||
//
|
|
||||||
this.ButtonAdd.Location = new System.Drawing.Point(561, 27);
|
|
||||||
this.ButtonAdd.Name = "ButtonAdd";
|
|
||||||
this.ButtonAdd.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.ButtonAdd.TabIndex = 1;
|
|
||||||
this.ButtonAdd.Text = "Добавить";
|
|
||||||
this.ButtonAdd.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
|
||||||
//
|
|
||||||
// ButtonRef
|
|
||||||
//
|
|
||||||
this.ButtonRef.Location = new System.Drawing.Point(561, 86);
|
|
||||||
this.ButtonRef.Name = "ButtonRef";
|
|
||||||
this.ButtonRef.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.ButtonRef.TabIndex = 2;
|
|
||||||
this.ButtonRef.Text = "Изменить";
|
|
||||||
this.ButtonRef.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonRef.Click += new System.EventHandler(this.ButtonUpd_Click);
|
|
||||||
//
|
|
||||||
// ButtonDel
|
|
||||||
//
|
|
||||||
this.ButtonDel.Location = new System.Drawing.Point(561, 144);
|
|
||||||
this.ButtonDel.Name = "ButtonDel";
|
|
||||||
this.ButtonDel.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.ButtonDel.TabIndex = 3;
|
|
||||||
this.ButtonDel.Text = "Удалить";
|
|
||||||
this.ButtonDel.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
|
||||||
//
|
|
||||||
// ButtonUpd
|
|
||||||
//
|
|
||||||
this.ButtonUpd.Location = new System.Drawing.Point(561, 194);
|
|
||||||
this.ButtonUpd.Name = "ButtonUpd";
|
|
||||||
this.ButtonUpd.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.ButtonUpd.TabIndex = 4;
|
|
||||||
this.ButtonUpd.Text = "Обновить";
|
|
||||||
this.ButtonUpd.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonUpd.Click += new System.EventHandler(this.ButtonRef_Click);
|
|
||||||
//
|
|
||||||
// FormComponents
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
|
||||||
this.Controls.Add(this.ButtonUpd);
|
|
||||||
this.Controls.Add(this.ButtonDel);
|
|
||||||
this.Controls.Add(this.ButtonRef);
|
|
||||||
this.Controls.Add(this.ButtonAdd);
|
|
||||||
this.Controls.Add(this.dataGridView);
|
|
||||||
this.Name = "FormComponents";
|
|
||||||
this.Text = "Компоненты";
|
|
||||||
this.Load += new System.EventHandler(this.FormComponents_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
private Button ButtonAdd;
|
|
||||||
private Button ButtonRef;
|
|
||||||
private Button ButtonDel;
|
|
||||||
private Button ButtonUpd;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,113 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using FoodOrders;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace FoodOrders
|
|
||||||
{
|
|
||||||
public partial class FormComponents : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IComponentLogic _logic;
|
|
||||||
public FormComponents(ILogger<FormComponents> logger, IComponentLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
private void FormComponents_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["ComponentName"].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(FormComponent));
|
|
||||||
if (service is FormComponent 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(FormComponent));
|
|
||||||
if (service is FormComponent 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 ComponentBindingModel
|
|
||||||
{
|
|
||||||
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>
|
|
143
FoodOrders/FoodOrders/FormCreateOrder.Designer.cs
generated
143
FoodOrders/FoodOrders/FormCreateOrder.Designer.cs
generated
@ -1,143 +0,0 @@
|
|||||||
namespace FoodOrders
|
|
||||||
{
|
|
||||||
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.labelDish = new System.Windows.Forms.Label();
|
|
||||||
this.labelCount = new System.Windows.Forms.Label();
|
|
||||||
this.labelSum = new System.Windows.Forms.Label();
|
|
||||||
this.comboBoxDish = new System.Windows.Forms.ComboBox();
|
|
||||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
|
||||||
this.textBoxSum = new System.Windows.Forms.TextBox();
|
|
||||||
this.ButtonSave = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelDish
|
|
||||||
//
|
|
||||||
this.labelDish.AutoSize = true;
|
|
||||||
this.labelDish.Location = new System.Drawing.Point(38, 30);
|
|
||||||
this.labelDish.Name = "labelDish";
|
|
||||||
this.labelDish.Size = new System.Drawing.Size(58, 20);
|
|
||||||
this.labelDish.TabIndex = 0;
|
|
||||||
this.labelDish.Text = "Блюдо:";
|
|
||||||
//
|
|
||||||
// labelCount
|
|
||||||
//
|
|
||||||
this.labelCount.AutoSize = true;
|
|
||||||
this.labelCount.Location = new System.Drawing.Point(38, 76);
|
|
||||||
this.labelCount.Name = "labelCount";
|
|
||||||
this.labelCount.Size = new System.Drawing.Size(93, 20);
|
|
||||||
this.labelCount.TabIndex = 1;
|
|
||||||
this.labelCount.Text = "Количество:";
|
|
||||||
//
|
|
||||||
// labelSum
|
|
||||||
//
|
|
||||||
this.labelSum.AutoSize = true;
|
|
||||||
this.labelSum.Location = new System.Drawing.Point(38, 125);
|
|
||||||
this.labelSum.Name = "labelSum";
|
|
||||||
this.labelSum.Size = new System.Drawing.Size(55, 20);
|
|
||||||
this.labelSum.TabIndex = 2;
|
|
||||||
this.labelSum.Text = "Сумма";
|
|
||||||
//
|
|
||||||
// comboBoxDish
|
|
||||||
//
|
|
||||||
this.comboBoxDish.FormattingEnabled = true;
|
|
||||||
this.comboBoxDish.Location = new System.Drawing.Point(148, 27);
|
|
||||||
this.comboBoxDish.Name = "comboBoxDish";
|
|
||||||
this.comboBoxDish.Size = new System.Drawing.Size(286, 28);
|
|
||||||
this.comboBoxDish.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// textBoxCount
|
|
||||||
//
|
|
||||||
this.textBoxCount.Location = new System.Drawing.Point(148, 69);
|
|
||||||
this.textBoxCount.Name = "textBoxCount";
|
|
||||||
this.textBoxCount.Size = new System.Drawing.Size(286, 27);
|
|
||||||
this.textBoxCount.TabIndex = 4;
|
|
||||||
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
|
|
||||||
//
|
|
||||||
// textBoxSum
|
|
||||||
//
|
|
||||||
this.textBoxSum.Location = new System.Drawing.Point(148, 118);
|
|
||||||
this.textBoxSum.Name = "textBoxSum";
|
|
||||||
this.textBoxSum.Size = new System.Drawing.Size(286, 27);
|
|
||||||
this.textBoxSum.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// ButtonSave
|
|
||||||
//
|
|
||||||
this.ButtonSave.Location = new System.Drawing.Point(211, 174);
|
|
||||||
this.ButtonSave.Name = "ButtonSave";
|
|
||||||
this.ButtonSave.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.ButtonSave.TabIndex = 6;
|
|
||||||
this.ButtonSave.Text = "Сохранить";
|
|
||||||
this.ButtonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// ButtonCancel
|
|
||||||
//
|
|
||||||
this.ButtonCancel.Location = new System.Drawing.Point(340, 174);
|
|
||||||
this.ButtonCancel.Name = "ButtonCancel";
|
|
||||||
this.ButtonCancel.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.ButtonCancel.TabIndex = 7;
|
|
||||||
this.ButtonCancel.Text = "Отмена";
|
|
||||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// FormCreateOrder
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(466, 229);
|
|
||||||
this.Controls.Add(this.ButtonCancel);
|
|
||||||
this.Controls.Add(this.ButtonSave);
|
|
||||||
this.Controls.Add(this.textBoxSum);
|
|
||||||
this.Controls.Add(this.textBoxCount);
|
|
||||||
this.Controls.Add(this.comboBoxDish);
|
|
||||||
this.Controls.Add(this.labelSum);
|
|
||||||
this.Controls.Add(this.labelCount);
|
|
||||||
this.Controls.Add(this.labelDish);
|
|
||||||
this.Name = "FormCreateOrder";
|
|
||||||
this.Text = "Заказ";
|
|
||||||
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label labelDish;
|
|
||||||
private Label labelCount;
|
|
||||||
private Label labelSum;
|
|
||||||
private ComboBox comboBoxDish;
|
|
||||||
private TextBox textBoxCount;
|
|
||||||
private TextBox textBoxSum;
|
|
||||||
private Button ButtonSave;
|
|
||||||
private Button ButtonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,157 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace FoodOrders
|
|
||||||
{
|
|
||||||
public partial class FormCreateOrder : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IDishLogic _logicD;
|
|
||||||
private readonly IOrderLogic _logicO;
|
|
||||||
private List<DishViewModel>? _list;
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return
|
|
||||||
Convert.ToInt32(comboBoxDish.SelectedValue);
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
comboBoxDish.SelectedValue = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public IDishModel? DishModel
|
|
||||||
{
|
|
||||||
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 FormCreateOrder(ILogger<FormCreateOrder> logger, IDishLogic
|
|
||||||
logicD, IOrderLogic logicO)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logicD = logicD;
|
|
||||||
_logicO = logicO;
|
|
||||||
}
|
|
||||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка изделий для заказа");
|
|
||||||
_list = _logicD.ReadList(null);
|
|
||||||
|
|
||||||
if (_list != null)
|
|
||||||
{
|
|
||||||
comboBoxDish.DisplayMember = "DishName";
|
|
||||||
comboBoxDish.ValueMember = "Id";
|
|
||||||
comboBoxDish.DataSource = _list;
|
|
||||||
comboBoxDish.SelectedItem = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void CalcSum()
|
|
||||||
{
|
|
||||||
if (comboBoxDish.SelectedValue != null &&
|
|
||||||
!string.IsNullOrEmpty(textBoxCount.Text))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(comboBoxDish.SelectedValue);
|
|
||||||
var dish = _logicD.ReadElement(new DishSearchModel
|
|
||||||
{
|
|
||||||
Id = id
|
|
||||||
});
|
|
||||||
int count = Convert.ToInt32(textBoxCount.Text);
|
|
||||||
textBoxSum.Text = Math.Round(count * (dish?.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 ComboBoxProduct_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 (comboBoxDish.SelectedValue == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Выберите изделие", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Создание заказа");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
|
||||||
{
|
|
||||||
DishId = Convert.ToInt32(comboBoxDish.SelectedValue),
|
|
||||||
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>
|
|
231
FoodOrders/FoodOrders/FormDish.Designer.cs
generated
231
FoodOrders/FoodOrders/FormDish.Designer.cs
generated
@ -1,231 +0,0 @@
|
|||||||
namespace FoodOrders
|
|
||||||
{
|
|
||||||
partial class FormDish
|
|
||||||
{
|
|
||||||
/// <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.groupBoxComponents = new System.Windows.Forms.GroupBox();
|
|
||||||
this.ButtonUpd = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonDel = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonRef = 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.Component = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.ButtonSave = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
|
||||||
this.labelCost = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
|
||||||
this.textBoxPrice = new System.Windows.Forms.TextBox();
|
|
||||||
this.groupBoxComponents.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// groupBoxComponents
|
|
||||||
//
|
|
||||||
this.groupBoxComponents.Controls.Add(this.ButtonUpd);
|
|
||||||
this.groupBoxComponents.Controls.Add(this.ButtonDel);
|
|
||||||
this.groupBoxComponents.Controls.Add(this.ButtonRef);
|
|
||||||
this.groupBoxComponents.Controls.Add(this.ButtonAdd);
|
|
||||||
this.groupBoxComponents.Controls.Add(this.dataGridView);
|
|
||||||
this.groupBoxComponents.Location = new System.Drawing.Point(12, 143);
|
|
||||||
this.groupBoxComponents.Name = "groupBoxComponents";
|
|
||||||
this.groupBoxComponents.Size = new System.Drawing.Size(821, 292);
|
|
||||||
this.groupBoxComponents.TabIndex = 0;
|
|
||||||
this.groupBoxComponents.TabStop = false;
|
|
||||||
this.groupBoxComponents.Text = "Компоненты";
|
|
||||||
//
|
|
||||||
// ButtonUpd
|
|
||||||
//
|
|
||||||
this.ButtonUpd.Location = new System.Drawing.Point(690, 206);
|
|
||||||
this.ButtonUpd.Name = "ButtonUpd";
|
|
||||||
this.ButtonUpd.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.ButtonUpd.TabIndex = 4;
|
|
||||||
this.ButtonUpd.Text = "Обновить";
|
|
||||||
this.ButtonUpd.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
|
||||||
//
|
|
||||||
// ButtonDel
|
|
||||||
//
|
|
||||||
this.ButtonDel.Location = new System.Drawing.Point(690, 161);
|
|
||||||
this.ButtonDel.Name = "ButtonDel";
|
|
||||||
this.ButtonDel.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.ButtonDel.TabIndex = 3;
|
|
||||||
this.ButtonDel.Text = "Удалить";
|
|
||||||
this.ButtonDel.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
|
||||||
//
|
|
||||||
// ButtonRef
|
|
||||||
//
|
|
||||||
this.ButtonRef.Location = new System.Drawing.Point(690, 114);
|
|
||||||
this.ButtonRef.Name = "ButtonRef";
|
|
||||||
this.ButtonRef.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.ButtonRef.TabIndex = 2;
|
|
||||||
this.ButtonRef.Text = "Изменить";
|
|
||||||
this.ButtonRef.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
|
||||||
//
|
|
||||||
// ButtonAdd
|
|
||||||
//
|
|
||||||
this.ButtonAdd.Location = new System.Drawing.Point(690, 67);
|
|
||||||
this.ButtonAdd.Name = "ButtonAdd";
|
|
||||||
this.ButtonAdd.Size = new System.Drawing.Size(94, 29);
|
|
||||||
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.Component,
|
|
||||||
this.Count});
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(6, 26);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(648, 260);
|
|
||||||
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;
|
|
||||||
//
|
|
||||||
// Component
|
|
||||||
//
|
|
||||||
this.Component.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
this.Component.HeaderText = "Компонент";
|
|
||||||
this.Component.MinimumWidth = 6;
|
|
||||||
this.Component.Name = "Component";
|
|
||||||
//
|
|
||||||
// Count
|
|
||||||
//
|
|
||||||
this.Count.HeaderText = "Количество";
|
|
||||||
this.Count.MinimumWidth = 6;
|
|
||||||
this.Count.Name = "Count";
|
|
||||||
this.Count.Width = 125;
|
|
||||||
//
|
|
||||||
// ButtonSave
|
|
||||||
//
|
|
||||||
this.ButtonSave.Location = new System.Drawing.Point(553, 455);
|
|
||||||
this.ButtonSave.Name = "ButtonSave";
|
|
||||||
this.ButtonSave.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.ButtonSave.TabIndex = 1;
|
|
||||||
this.ButtonSave.Text = "Сохранить";
|
|
||||||
this.ButtonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// ButtonCancel
|
|
||||||
//
|
|
||||||
this.ButtonCancel.Location = new System.Drawing.Point(678, 455);
|
|
||||||
this.ButtonCancel.Name = "ButtonCancel";
|
|
||||||
this.ButtonCancel.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.ButtonCancel.TabIndex = 2;
|
|
||||||
this.ButtonCancel.Text = "Отмена";
|
|
||||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
this.labelName.AutoSize = true;
|
|
||||||
this.labelName.Location = new System.Drawing.Point(48, 37);
|
|
||||||
this.labelName.Name = "labelName";
|
|
||||||
this.labelName.Size = new System.Drawing.Size(80, 20);
|
|
||||||
this.labelName.TabIndex = 3;
|
|
||||||
this.labelName.Text = "Название:";
|
|
||||||
//
|
|
||||||
// labelCost
|
|
||||||
//
|
|
||||||
this.labelCost.AutoSize = true;
|
|
||||||
this.labelCost.Location = new System.Drawing.Point(48, 79);
|
|
||||||
this.labelCost.Name = "labelCost";
|
|
||||||
this.labelCost.Size = new System.Drawing.Size(86, 20);
|
|
||||||
this.labelCost.TabIndex = 4;
|
|
||||||
this.labelCost.Text = "Стоимость:";
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
this.textBoxName.Location = new System.Drawing.Point(144, 30);
|
|
||||||
this.textBoxName.Name = "textBoxName";
|
|
||||||
this.textBoxName.Size = new System.Drawing.Size(353, 27);
|
|
||||||
this.textBoxName.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// textBoxPrice
|
|
||||||
//
|
|
||||||
this.textBoxPrice.Location = new System.Drawing.Point(144, 72);
|
|
||||||
this.textBoxPrice.Name = "textBoxPrice";
|
|
||||||
this.textBoxPrice.Size = new System.Drawing.Size(192, 27);
|
|
||||||
this.textBoxPrice.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// FormDish
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(845, 515);
|
|
||||||
this.Controls.Add(this.textBoxPrice);
|
|
||||||
this.Controls.Add(this.textBoxName);
|
|
||||||
this.Controls.Add(this.labelCost);
|
|
||||||
this.Controls.Add(this.labelName);
|
|
||||||
this.Controls.Add(this.ButtonCancel);
|
|
||||||
this.Controls.Add(this.ButtonSave);
|
|
||||||
this.Controls.Add(this.groupBoxComponents);
|
|
||||||
this.Name = "FormDish";
|
|
||||||
this.Text = "Блюдо";
|
|
||||||
this.groupBoxComponents.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private GroupBox groupBoxComponents;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
private Button ButtonSave;
|
|
||||||
private Button ButtonCancel;
|
|
||||||
private DataGridViewTextBoxColumn ID;
|
|
||||||
private DataGridViewTextBoxColumn Component;
|
|
||||||
private DataGridViewTextBoxColumn Count;
|
|
||||||
private Button ButtonUpd;
|
|
||||||
private Button ButtonDel;
|
|
||||||
private Button ButtonRef;
|
|
||||||
private Button ButtonAdd;
|
|
||||||
private Label labelName;
|
|
||||||
private Label labelCost;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private TextBox textBoxPrice;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,223 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using AbstractFoodOrdersContracts.SearchModels;
|
|
||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace FoodOrders
|
|
||||||
{
|
|
||||||
public partial class FormDish : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IDishLogic _logic;
|
|
||||||
private int? _id;
|
|
||||||
private Dictionary<int, (IComponentModel, int)> _productComponents;
|
|
||||||
public int Id { set { _id = value; } }
|
|
||||||
|
|
||||||
public FormDish(ILogger<FormDish> logger, IDishLogic logic) {
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
_productComponents = new Dictionary<int, (IComponentModel, int)>();
|
|
||||||
}
|
|
||||||
private void FormProduct_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_id.HasValue)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка изделия");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var view = _logic.ReadElement(new DishSearchModel
|
|
||||||
{
|
|
||||||
Id =
|
|
||||||
_id.Value
|
|
||||||
});
|
|
||||||
if (view != null)
|
|
||||||
{
|
|
||||||
textBoxName.Text = view.DishName;
|
|
||||||
textBoxPrice.Text = view.Price.ToString();
|
|
||||||
_productComponents = view.DishComponents ?? new
|
|
||||||
Dictionary<int, (IComponentModel, int)>();
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки изделия");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка компонент изделия");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_productComponents != null)
|
|
||||||
{
|
|
||||||
dataGridView.Rows.Clear();
|
|
||||||
foreach (var pc in _productComponents)
|
|
||||||
{
|
|
||||||
dataGridView.Rows.Add(new object[] { pc.Key,pc.Value.Item1.ComponentName, pc.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(FormDishComponent));
|
|
||||||
if (service is FormDishComponent form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (form.ComponentModel == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
|
||||||
if (_productComponents.ContainsKey(form.Id))
|
|
||||||
{
|
|
||||||
_productComponents[form.Id] = (form.ComponentModel,
|
|
||||||
form.Count);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_productComponents.Add(form.Id, (form.ComponentModel,
|
|
||||||
form.Count));
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
var service =
|
|
||||||
Program.ServiceProvider?.GetService(typeof(FormDishComponent));
|
|
||||||
if (service is FormDishComponent form)
|
|
||||||
{
|
|
||||||
int id =
|
|
||||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
|
||||||
form.Id = id;
|
|
||||||
form.Count = _productComponents[id].Item2;
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (form.ComponentModel == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
|
||||||
_productComponents[form.Id] = (form.ComponentModel, 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("Удаление компонента: { ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value);
|
|
||||||
|
|
||||||
_productComponents?.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 (_productComponents == null || _productComponents.Count == 0)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните компоненты", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Сохранение изделия");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var model = new DishBindingModel
|
|
||||||
{
|
|
||||||
Id = _id ?? 0,
|
|
||||||
DishName = textBoxName.Text,
|
|
||||||
Price = Convert.ToDouble(textBoxPrice.Text),
|
|
||||||
DishComponents = _productComponents
|
|
||||||
};
|
|
||||||
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 _productComponents)
|
|
||||||
{
|
|
||||||
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="Component.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
119
FoodOrders/FoodOrders/FormDishComponent.Designer.cs
generated
119
FoodOrders/FoodOrders/FormDishComponent.Designer.cs
generated
@ -1,119 +0,0 @@
|
|||||||
namespace FoodOrders
|
|
||||||
{
|
|
||||||
partial class FormDishComponent
|
|
||||||
{
|
|
||||||
/// <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.labelComponent = new System.Windows.Forms.Label();
|
|
||||||
this.labelCount = new System.Windows.Forms.Label();
|
|
||||||
this.comboBoxComponent = new System.Windows.Forms.ComboBox();
|
|
||||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
|
||||||
this.ButtonSave = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelComponent
|
|
||||||
//
|
|
||||||
this.labelComponent.AutoSize = true;
|
|
||||||
this.labelComponent.Location = new System.Drawing.Point(38, 45);
|
|
||||||
this.labelComponent.Name = "labelComponent";
|
|
||||||
this.labelComponent.Size = new System.Drawing.Size(91, 20);
|
|
||||||
this.labelComponent.TabIndex = 0;
|
|
||||||
this.labelComponent.Text = "Компонент:";
|
|
||||||
//
|
|
||||||
// labelCount
|
|
||||||
//
|
|
||||||
this.labelCount.AutoSize = true;
|
|
||||||
this.labelCount.Location = new System.Drawing.Point(38, 92);
|
|
||||||
this.labelCount.Name = "labelCount";
|
|
||||||
this.labelCount.Size = new System.Drawing.Size(93, 20);
|
|
||||||
this.labelCount.TabIndex = 1;
|
|
||||||
this.labelCount.Text = "Количество:";
|
|
||||||
//
|
|
||||||
// comboBoxComponent
|
|
||||||
//
|
|
||||||
this.comboBoxComponent.FormattingEnabled = true;
|
|
||||||
this.comboBoxComponent.Location = new System.Drawing.Point(150, 37);
|
|
||||||
this.comboBoxComponent.Name = "comboBoxComponent";
|
|
||||||
this.comboBoxComponent.Size = new System.Drawing.Size(289, 28);
|
|
||||||
this.comboBoxComponent.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// textBoxCount
|
|
||||||
//
|
|
||||||
this.textBoxCount.Location = new System.Drawing.Point(150, 85);
|
|
||||||
this.textBoxCount.Name = "textBoxCount";
|
|
||||||
this.textBoxCount.Size = new System.Drawing.Size(289, 27);
|
|
||||||
this.textBoxCount.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// ButtonSave
|
|
||||||
//
|
|
||||||
this.ButtonSave.Location = new System.Drawing.Point(195, 138);
|
|
||||||
this.ButtonSave.Name = "ButtonSave";
|
|
||||||
this.ButtonSave.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.ButtonSave.TabIndex = 4;
|
|
||||||
this.ButtonSave.Text = "Сохранить";
|
|
||||||
this.ButtonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// ButtonCancel
|
|
||||||
//
|
|
||||||
this.ButtonCancel.Location = new System.Drawing.Point(334, 138);
|
|
||||||
this.ButtonCancel.Name = "ButtonCancel";
|
|
||||||
this.ButtonCancel.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.ButtonCancel.TabIndex = 5;
|
|
||||||
this.ButtonCancel.Text = "Отмена";
|
|
||||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// FormDishComponent
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(476, 185);
|
|
||||||
this.Controls.Add(this.ButtonCancel);
|
|
||||||
this.Controls.Add(this.ButtonSave);
|
|
||||||
this.Controls.Add(this.textBoxCount);
|
|
||||||
this.Controls.Add(this.comboBoxComponent);
|
|
||||||
this.Controls.Add(this.labelCount);
|
|
||||||
this.Controls.Add(this.labelComponent);
|
|
||||||
this.Name = "FormDishComponent";
|
|
||||||
this.Text = "Компонент изделия";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label labelComponent;
|
|
||||||
private Label labelCount;
|
|
||||||
private ComboBox comboBoxComponent;
|
|
||||||
private TextBox textBoxCount;
|
|
||||||
private Button ButtonSave;
|
|
||||||
private Button ButtonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using AbstractFoodOrdersContracts.ViewModels;
|
|
||||||
using AbstractFoodOrdersDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace FoodOrders
|
|
||||||
{
|
|
||||||
public partial class FormDishComponent : Form
|
|
||||||
{
|
|
||||||
private readonly List<ComponentViewModel>? _list;
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return
|
|
||||||
Convert.ToInt32(comboBoxComponent.SelectedValue);
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
comboBoxComponent.SelectedValue = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public IComponentModel? ComponentModel
|
|
||||||
{
|
|
||||||
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 FormDishComponent(IComponentLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_list = logic.ReadList(null);
|
|
||||||
if (_list != null)
|
|
||||||
{
|
|
||||||
comboBoxComponent.DisplayMember = "ComponentName";
|
|
||||||
comboBoxComponent.ValueMember = "Id";
|
|
||||||
comboBoxComponent.DataSource = _list;
|
|
||||||
comboBoxComponent.SelectedItem = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (comboBoxComponent.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>
|
|
119
FoodOrders/FoodOrders/FormDishes.Designer.cs
generated
119
FoodOrders/FoodOrders/FormDishes.Designer.cs
generated
@ -1,119 +0,0 @@
|
|||||||
namespace FoodOrders
|
|
||||||
{
|
|
||||||
partial class FormDishes
|
|
||||||
{
|
|
||||||
/// <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.buttonRef = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUpd = 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();
|
|
||||||
//
|
|
||||||
// buttonRef
|
|
||||||
//
|
|
||||||
this.buttonRef.Location = new System.Drawing.Point(523, 186);
|
|
||||||
this.buttonRef.Name = "buttonRef";
|
|
||||||
this.buttonRef.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.buttonRef.TabIndex = 9;
|
|
||||||
this.buttonRef.Text = "Обновить";
|
|
||||||
this.buttonRef.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click);
|
|
||||||
//
|
|
||||||
// buttonDel
|
|
||||||
//
|
|
||||||
this.buttonDel.Location = new System.Drawing.Point(523, 128);
|
|
||||||
this.buttonDel.Name = "buttonDel";
|
|
||||||
this.buttonDel.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.buttonDel.TabIndex = 8;
|
|
||||||
this.buttonDel.Text = "Удалить";
|
|
||||||
this.buttonDel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click);
|
|
||||||
//
|
|
||||||
// buttonUpd
|
|
||||||
//
|
|
||||||
this.buttonUpd.Location = new System.Drawing.Point(523, 71);
|
|
||||||
this.buttonUpd.Name = "buttonUpd";
|
|
||||||
this.buttonUpd.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.buttonUpd.TabIndex = 7;
|
|
||||||
this.buttonUpd.Text = "Изменить";
|
|
||||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click);
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(523, 14);
|
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.buttonAdd.TabIndex = 6;
|
|
||||||
this.buttonAdd.Text = "Добавить";
|
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.BackgroundColor = System.Drawing.Color.White;
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(1, 2);
|
|
||||||
this.dataGridView.MultiSelect = false;
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowHeadersVisible = false;
|
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
|
||||||
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(489, 449);
|
|
||||||
this.dataGridView.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// FormDishes
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(642, 450);
|
|
||||||
this.Controls.Add(this.buttonRef);
|
|
||||||
this.Controls.Add(this.buttonDel);
|
|
||||||
this.Controls.Add(this.buttonUpd);
|
|
||||||
this.Controls.Add(this.buttonAdd);
|
|
||||||
this.Controls.Add(this.dataGridView);
|
|
||||||
this.Name = "FormDishes";
|
|
||||||
this.Text = "Блюда";
|
|
||||||
this.Load += new System.EventHandler(this.FormDishes_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonRef;
|
|
||||||
private Button buttonDel;
|
|
||||||
private Button buttonUpd;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,112 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace FoodOrders
|
|
||||||
{
|
|
||||||
public partial class FormDishes : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IDishLogic _logic;
|
|
||||||
|
|
||||||
public FormDishes(ILogger<FormDishes> logger, IDishLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormDishes_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["DishComponents"].Visible = false;
|
|
||||||
dataGridView.Columns["DishName"].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(FormDish));
|
|
||||||
if (service is FormDish 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(FormDish));
|
|
||||||
if (service is FormDish 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 DishBindingModel { 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>
|
|
177
FoodOrders/FoodOrders/FormMain.Designer.cs
generated
177
FoodOrders/FoodOrders/FormMain.Designer.cs
generated
@ -1,177 +0,0 @@
|
|||||||
namespace FoodOrders
|
|
||||||
{
|
|
||||||
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.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.КомпонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.БлюдаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
this.ButtonCreateOrder = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonTakeOrderInWork = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonOrderReady = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonIssuedOrder = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonRef = new System.Windows.Forms.Button();
|
|
||||||
this.menuStrip.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// menuStrip
|
|
||||||
//
|
|
||||||
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
|
||||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.справочникиToolStripMenuItem});
|
|
||||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.menuStrip.Name = "menuStrip";
|
|
||||||
this.menuStrip.Size = new System.Drawing.Size(1104, 28);
|
|
||||||
this.menuStrip.TabIndex = 0;
|
|
||||||
this.menuStrip.Text = "menuStrip1";
|
|
||||||
//
|
|
||||||
// справочникиToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.КомпонентыToolStripMenuItem,
|
|
||||||
this.БлюдаToolStripMenuItem});
|
|
||||||
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
|
||||||
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
|
|
||||||
this.справочникиToolStripMenuItem.Text = "Справочники";
|
|
||||||
//
|
|
||||||
// КомпонентыToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
|
|
||||||
this.КомпонентыToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
|
|
||||||
this.КомпонентыToolStripMenuItem.Text = "Компоненты";
|
|
||||||
this.КомпонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// БлюдаToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.БлюдаToolStripMenuItem.Name = "БлюдаToolStripMenuItem";
|
|
||||||
this.БлюдаToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
|
|
||||||
this.БлюдаToolStripMenuItem.Text = "Блюда";
|
|
||||||
this.БлюдаToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(0, 40);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(798, 408);
|
|
||||||
this.dataGridView.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// ButtonCreateOrder
|
|
||||||
//
|
|
||||||
this.ButtonCreateOrder.Location = new System.Drawing.Point(831, 82);
|
|
||||||
this.ButtonCreateOrder.Name = "ButtonCreateOrder";
|
|
||||||
this.ButtonCreateOrder.Size = new System.Drawing.Size(241, 29);
|
|
||||||
this.ButtonCreateOrder.TabIndex = 2;
|
|
||||||
this.ButtonCreateOrder.Text = "Создать заказ";
|
|
||||||
this.ButtonCreateOrder.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
|
|
||||||
//
|
|
||||||
// ButtonTakeOrderInWork
|
|
||||||
//
|
|
||||||
this.ButtonTakeOrderInWork.Location = new System.Drawing.Point(831, 141);
|
|
||||||
this.ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork";
|
|
||||||
this.ButtonTakeOrderInWork.Size = new System.Drawing.Size(241, 29);
|
|
||||||
this.ButtonTakeOrderInWork.TabIndex = 3;
|
|
||||||
this.ButtonTakeOrderInWork.Text = "Отдать заказ на выполнение";
|
|
||||||
this.ButtonTakeOrderInWork.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
|
|
||||||
//
|
|
||||||
// ButtonOrderReady
|
|
||||||
//
|
|
||||||
this.ButtonOrderReady.Location = new System.Drawing.Point(831, 202);
|
|
||||||
this.ButtonOrderReady.Name = "ButtonOrderReady";
|
|
||||||
this.ButtonOrderReady.Size = new System.Drawing.Size(241, 29);
|
|
||||||
this.ButtonOrderReady.TabIndex = 4;
|
|
||||||
this.ButtonOrderReady.Text = "Заказ готов";
|
|
||||||
this.ButtonOrderReady.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
|
|
||||||
//
|
|
||||||
// ButtonIssuedOrder
|
|
||||||
//
|
|
||||||
this.ButtonIssuedOrder.Location = new System.Drawing.Point(831, 264);
|
|
||||||
this.ButtonIssuedOrder.Name = "ButtonIssuedOrder";
|
|
||||||
this.ButtonIssuedOrder.Size = new System.Drawing.Size(241, 29);
|
|
||||||
this.ButtonIssuedOrder.TabIndex = 5;
|
|
||||||
this.ButtonIssuedOrder.Text = "Заказ выдан";
|
|
||||||
this.ButtonIssuedOrder.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
|
|
||||||
//
|
|
||||||
// ButtonRef
|
|
||||||
//
|
|
||||||
this.ButtonRef.Location = new System.Drawing.Point(831, 331);
|
|
||||||
this.ButtonRef.Name = "ButtonRef";
|
|
||||||
this.ButtonRef.Size = new System.Drawing.Size(241, 29);
|
|
||||||
this.ButtonRef.TabIndex = 6;
|
|
||||||
this.ButtonRef.Text = "Обновить список";
|
|
||||||
this.ButtonRef.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
|
||||||
//
|
|
||||||
// FormMain
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(1104, 470);
|
|
||||||
this.Controls.Add(this.ButtonRef);
|
|
||||||
this.Controls.Add(this.ButtonIssuedOrder);
|
|
||||||
this.Controls.Add(this.ButtonOrderReady);
|
|
||||||
this.Controls.Add(this.ButtonTakeOrderInWork);
|
|
||||||
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 справочникиToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem КомпонентыToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem БлюдаToolStripMenuItem;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
private Button ButtonCreateOrder;
|
|
||||||
private Button ButtonTakeOrderInWork;
|
|
||||||
private Button ButtonOrderReady;
|
|
||||||
private Button ButtonIssuedOrder;
|
|
||||||
private Button ButtonRef;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,161 +0,0 @@
|
|||||||
using AbstractFoodOrdersContracts.BindingModels;
|
|
||||||
using AbstractFoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace FoodOrders
|
|
||||||
{
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _orderLogic.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["DishId"].Visible = false;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service =
|
|
||||||
Program.ServiceProvider?.GetService(typeof(FormComponents));
|
|
||||||
if (service is FormComponents form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var service =
|
|
||||||
Program.ServiceProvider?.GetService(typeof(FormDishes));
|
|
||||||
if (service is FormDishes 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 });
|
|
||||||
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 });
|
|
||||||
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 });
|
|
||||||
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 AbstractFoodOrdersBusinessLogic.BusinessLogics;
|
|
||||||
using AbstractFoodOrdersContracts.BusinessLogicsContracts;
|
|
||||||
using AbstractFoodOrdersContracts.StoragesContracts;
|
|
||||||
using AbstractFoodOrdersDatabaseImplement.Implements;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using NLog.Extensions.Logging;
|
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace FoodOrders
|
namespace FoodOrders
|
||||||
{
|
{
|
||||||
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.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
@ -22,32 +11,7 @@ namespace FoodOrders
|
|||||||
// 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();
|
||||||
var services = new ServiceCollection();
|
Application.Run(new Form1());
|
||||||
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<IComponentStorage, ComponentStorage>();
|
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
|
||||||
services.AddTransient<IDishStorage, DishStorage>();
|
|
||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
|
||||||
services.AddTransient<IDishLogic, DishLogic>();
|
|
||||||
services.AddTransient<FormMain>();
|
|
||||||
services.AddTransient<FormComponent>();
|
|
||||||
services.AddTransient<FormComponents>();
|
|
||||||
services.AddTransient<FormCreateOrder>();
|
|
||||||
services.AddTransient<FormDish>();
|
|
||||||
services.AddTransient<FormDishComponent>();
|
|
||||||
services.AddTransient<FormDishes>();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<configuration>
|
|
||||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
autoReload="true" internalLogLevel="Info">
|
|
||||||
|
|
||||||
<targets>
|
|
||||||
<target xsi:type="File" name="tofile" fileName="${basedir}/${shortdate}.log" />
|
|
||||||
</targets>
|
|
||||||
|
|
||||||
<rules>
|
|
||||||
<logger name="*" minlevel="Debug" writeTo="tofile" />
|
|
||||||
</rules>
|
|
||||||
</nlog>
|
|
||||||
</configuration>
|
|
Loading…
Reference in New Issue
Block a user