ПИбд-23 Валова А. Д. Lab_2_Hard_ #13
@ -13,7 +13,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarView", "SushiBarVie
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarListImplement", "SushiBarListImplement_\SushiBarListImplement.csproj", "{AF2B4854-10FE-45CC-BA64-0C0B93BF41C4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarBusinessLogic", "SushiBarBusinessLogic_\SushiBarBusinessLogic.csproj", "{D7936C41-351B-43FD-B90B-5477375EEC1E}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarBusinessLogic", "SushiBarBusinessLogic_\SushiBarBusinessLogic.csproj", "{D7936C41-351B-43FD-B90B-5477375EEC1E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarFileImplement", "SushiBarFileImplement\SushiBarFileImplement.csproj", "{3FDA8B7A-9E62-4A1B-B926-DC71C6C5812F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -97,6 +99,18 @@ Global
|
||||
{D7936C41-351B-43FD-B90B-5477375EEC1E}.Release|x64.Build.0 = Release|Any CPU
|
||||
{D7936C41-351B-43FD-B90B-5477375EEC1E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{D7936C41-351B-43FD-B90B-5477375EEC1E}.Release|x86.Build.0 = Release|Any CPU
|
||||
{3FDA8B7A-9E62-4A1B-B926-DC71C6C5812F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3FDA8B7A-9E62-4A1B-B926-DC71C6C5812F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3FDA8B7A-9E62-4A1B-B926-DC71C6C5812F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{3FDA8B7A-9E62-4A1B-B926-DC71C6C5812F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{3FDA8B7A-9E62-4A1B-B926-DC71C6C5812F}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{3FDA8B7A-9E62-4A1B-B926-DC71C6C5812F}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{3FDA8B7A-9E62-4A1B-B926-DC71C6C5812F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3FDA8B7A-9E62-4A1B-B926-DC71C6C5812F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3FDA8B7A-9E62-4A1B-B926-DC71C6C5812F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{3FDA8B7A-9E62-4A1B-B926-DC71C6C5812F}.Release|x64.Build.0 = Release|Any CPU
|
||||
{3FDA8B7A-9E62-4A1B-B926-DC71C6C5812F}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{3FDA8B7A-9E62-4A1B-B926-DC71C6C5812F}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -17,10 +17,13 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
private readonly IShopStorage _shopStorage;
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopStorage shopStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_shopStorage = shopStorage;
|
||||
}
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
@ -60,6 +63,22 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
var order = _orderStorage.GetElement(new OrderSearchModel
|
||||
{
|
||||
Id = model.Id,
|
||||
});
|
||||
if (order == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(order));
|
||||
}
|
||||
if (!_shopStorage.RestockingShops(new SupplyBindingModel
|
||||
{
|
||||
SushiId = order.SushiId,
|
||||
Count = order.Count
|
||||
}))
|
||||
{
|
||||
throw new ArgumentException("Недостаточно места");
|
||||
}
|
||||
return ChangeStatus(model, OrderStatus.Выдан);
|
||||
}
|
||||
|
||||
@ -75,7 +94,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
}
|
||||
if (model.Count <= 0)
|
||||
{
|
||||
throw new ArgumentException("Колличество пиццы в заказе не может быть меньше 1", nameof(model.Count));
|
||||
throw new ArgumentException("Колличество суши в заказе не может быть меньше 1", nameof(model.Count));
|
||||
}
|
||||
if (model.Sum <= 0)
|
||||
{
|
@ -5,10 +5,10 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace SushiBarBusinessLogic.BusinessLogics
|
||||
{
|
||||
@ -156,5 +156,21 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
|
||||
public bool Sale(SupplySearchModel model)
|
||||
{
|
||||
if (!model.SushiId.HasValue || !model.Count.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_logger.LogInformation("Check sushi count in all shops");
|
||||
if (_shopStorage.Sale(model))
|
||||
{
|
||||
_logger.LogInformation("Selling sucsess");
|
||||
return true;
|
||||
}
|
||||
_logger.LogInformation("Selling failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
@ -93,11 +92,11 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.SushiName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия пиццы", nameof(model.SushiName));
|
||||
throw new ArgumentNullException("Нет названия суши", nameof(model.SushiName));
|
||||
}
|
||||
if (model.Price <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена пиццы должна быть больше 0", nameof(model.Price));
|
||||
throw new ArgumentNullException("Цена суши должна быть больше 0", nameof(model.Price));
|
||||
}
|
||||
if (model.SushiComponents == null || model.SushiComponents.Count == 0)
|
||||
{
|
||||
@ -110,7 +109,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Пицца с таким названием уже есть");
|
||||
throw new InvalidOperationException("Суши с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,6 @@ namespace SushiBarContracts.BindingModels
|
||||
public string Adress { get; set; } = string.Empty;
|
||||
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
||||
public Dictionary<int, (ISushiModel, int)> ShopSushis { get; set; } = new();
|
||||
|
||||
public int SushiMaxCount { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ namespace SushiBarContracts.BindingModels
|
||||
public int SushiId { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,5 +17,6 @@ namespace SushiBarContracts.BusinessLogicsContracts
|
||||
bool Update(ShopBindingModel model);
|
||||
bool Delete(ShopBindingModel model);
|
||||
bool MakeSupply(SupplyBindingModel model);
|
||||
bool Sale(SupplySearchModel model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,4 +11,4 @@ namespace SushiBarContracts.SearchModels
|
||||
public int? Id { get; set; }
|
||||
public string? ShopName { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
SushiBar/SushiBarContracts/SearchModels/SupplySearchModel.cs
Normal file
14
SushiBar/SushiBarContracts/SearchModels/SupplySearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SushiBarContracts.SearchModels
|
||||
{
|
||||
public class SupplySearchModel
|
||||
{
|
||||
public int? SushiId { get; set; }
|
||||
public int? Count { get; set; }
|
||||
}
|
||||
}
|
@ -17,5 +17,7 @@ namespace SushiBarContracts.StoragesContracts
|
||||
ShopViewModel? Insert(ShopBindingModel model);
|
||||
ShopViewModel? Update(ShopBindingModel model);
|
||||
ShopViewModel? Delete(ShopBindingModel model);
|
||||
bool Sale(SupplySearchModel model);
|
||||
bool RestockingShops(SupplyBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,11 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SushiBarDataModels.Models;
|
||||
using SushiBarContracts.ViewModels;
|
||||
|
||||
namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class ShopViewModel
|
||||
public class ShopViewModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название")]
|
||||
@ -18,5 +19,7 @@ namespace SushiBarContracts.ViewModels
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime OpeningDate { get; set; }
|
||||
public Dictionary<int, (ISushiModel, int)> ShopSushis { get; set; } = new();
|
||||
[DisplayName("Вместимость")]
|
||||
public int SushiMaxCount { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ namespace SushiBarDataModels.Models
|
||||
string Adress { get; }
|
||||
DateTime OpeningDate { get; }
|
||||
Dictionary<int, (ISushiModel, int)> ShopSushis { get; }
|
||||
public int SushiMaxCount { get; }
|
||||
}
|
||||
}
|
||||
|
62
SushiBar/SushiBarFileImplement/DataFileSingleton.cs
Normal file
62
SushiBar/SushiBarFileImplement/DataFileSingleton.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using SushiBarFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SushiBarFileImplement
|
||||
{
|
||||
internal class DataFileSingleton
|
||||
{
|
||||
private static DataFileSingleton? instance;
|
||||
private readonly string ComponentFileName = "Component.xml";
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string SushiFileName = "Sushi.xml";
|
||||
private readonly string ShopFileName = "Shop.xml";
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Sushi> Sushis { get; private set; }
|
||||
public List<Shop> Shops { 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 SaveSushis() => SaveData(Sushis, SushiFileName, "Sushis", x => x.GetXElement);
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
|
||||
|
||||
private DataFileSingleton()
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||
Sushis = LoadData(SushiFileName, "Sushi", x => Sushi.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
Shops = LoadData(ShopFileName, "Shop", x => Shop.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SushiBarFileImplement.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;
|
||||
}
|
||||
}
|
||||
}
|
94
SushiBar/SushiBarFileImplement/Implements/OrderStorage.cs
Normal file
94
SushiBar/SushiBarFileImplement/Implements/OrderStorage.cs
Normal file
@ -0,0 +1,94 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SushiBarFileImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
|
||||
public OrderStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList() => source.Orders.Select(x => AttachSushiName(x.GetViewModel)).ToList();
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Orders.Where(x => x.Id == model.Id).Select(x => AttachSushiName(x.GetViewModel)).ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return AttachSushiName(source.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel);
|
||||
}
|
||||
|
||||
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 AttachSushiName(newOrder.GetViewModel);
|
||||
}
|
||||
|
||||
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 AttachSushiName(order.GetViewModel);
|
||||
}
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order != null)
|
||||
{
|
||||
source.Orders.Remove(order);
|
||||
source.SaveOrders();
|
||||
return AttachSushiName(order.GetViewModel);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private OrderViewModel? AttachSushiName(OrderViewModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var sushi = source.Sushis.FirstOrDefault(x => x.Id == model.SushiId);
|
||||
if (sushi != null)
|
||||
{
|
||||
model.SushiName = sushi.SushiName;
|
||||
}
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
154
SushiBar/SushiBarFileImplement/Implements/ShopStorage.cs
Normal file
154
SushiBar/SushiBarFileImplement/Implements/ShopStorage.cs
Normal file
@ -0,0 +1,154 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SushiBarFileImplement.Models;
|
||||
|
||||
namespace SushiBarFileImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
|
||||
public ShopStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
return source.Shops.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Shops.Where(x => x.ShopName.Contains(model.ShopName)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return source.Shops.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Insert(ShopBindingModel model)
|
||||
{
|
||||
model.Id = source.Shops.Count > 0 ? source.Shops.Max(x => x.Id) + 1 : 1;
|
||||
var newShop = Shop.Create(model);
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Shops.Add(newShop);
|
||||
source.SaveShops();
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Update(ShopBindingModel model)
|
||||
{
|
||||
var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (shop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
shop.Update(model);
|
||||
source.SaveShops();
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Delete(ShopBindingModel model)
|
||||
{
|
||||
var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (shop != null)
|
||||
{
|
||||
source.Shops.Remove(shop);
|
||||
source.SaveShops();
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Sale(SupplySearchModel model)
|
||||
{
|
||||
if (model == null || !model.SushiId.HasValue || !model.Count.HasValue)
|
||||
return false;
|
||||
int remainingSpace = source.Shops.Select(x => x.Sushis.ContainsKey(model.SushiId.Value) ? x.Sushis[model.SushiId.Value] : 0).Sum();
|
||||
if (remainingSpace < model.Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var shops = source.Shops.Where(x => x.Sushis.ContainsKey(model.SushiId.Value)).OrderByDescending(x => x.Sushis[model.SushiId.Value]).ToList();
|
||||
foreach (var shop in shops)
|
||||
{
|
||||
int residue = model.Count.Value - shop.Sushis[model.SushiId.Value];
|
||||
if (residue > 0)
|
||||
{
|
||||
shop.Sushis.Remove(model.SushiId.Value);
|
||||
shop.SushisUpdate();
|
||||
model.Count = residue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (residue == 0)
|
||||
{
|
||||
shop.Sushis.Remove(model.SushiId.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
shop.Sushis[model.SushiId.Value] = -residue;
|
||||
}
|
||||
shop.SushisUpdate();
|
||||
source.SaveShops();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
source.SaveShops();
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool RestockingShops(SupplyBindingModel model)
|
||||
{
|
||||
if (model == null || source.Shops.Select(x => x.SushiMaxCount - x.ShopSushis.Select(y => y.Value.Item2).Sum()).Sum() < model.Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
foreach (Shop shop in source.Shops)
|
||||
{
|
||||
int free_places = shop.SushiMaxCount - shop.ShopSushis.Select(x => x.Value.Item2).Sum();
|
||||
if (free_places <= 0)
|
||||
continue;
|
||||
free_places = Math.Min(free_places, model.Count);
|
||||
model.Count -= free_places;
|
||||
if (shop.Sushis.ContainsKey(model.SushiId))
|
||||
{
|
||||
shop.Sushis[model.SushiId] += free_places;
|
||||
}
|
||||
else
|
||||
{
|
||||
shop.Sushis.Add(model.SushiId, free_places);
|
||||
}
|
||||
shop.SushisUpdate();
|
||||
if (model.Count == 0)
|
||||
{
|
||||
source.SaveShops();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
86
SushiBar/SushiBarFileImplement/Implements/SushiStorage.cs
Normal file
86
SushiBar/SushiBarFileImplement/Implements/SushiStorage.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SushiBarFileImplement.Implements
|
||||
{
|
||||
public class SushiStorage : ISushiStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
|
||||
public SushiStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<SushiViewModel> GetFullList()
|
||||
{
|
||||
return source.Sushis.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<SushiViewModel> GetFilteredList(SushiSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.SushiName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Sushis.Where(x => x.SushiName.Contains(model.SushiName)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public SushiViewModel? GetElement(SushiSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.SushiName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return source.Sushis.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.SushiName) && x.SushiName == model.SushiName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public SushiViewModel? Insert(SushiBindingModel model)
|
||||
{
|
||||
model.Id = source.Sushis.Count > 0 ? source.Sushis.Max(x => x.Id) + 1 : 1;
|
||||
var newSushi = Sushi.Create(model);
|
||||
if (newSushi == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Sushis.Add(newSushi);
|
||||
source.SaveSushis();
|
||||
return newSushi.GetViewModel;
|
||||
}
|
||||
|
||||
public SushiViewModel? Update(SushiBindingModel model)
|
||||
{
|
||||
var Sushi = source.Sushis.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (Sushi == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Sushi.Update(model);
|
||||
source.SaveSushis();
|
||||
return Sushi.GetViewModel;
|
||||
}
|
||||
|
||||
public SushiViewModel? Delete(SushiBindingModel model)
|
||||
{
|
||||
var Sushi = source.Sushis.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (Sushi != null)
|
||||
{
|
||||
source.Sushis.Remove(Sushi);
|
||||
source.SaveSushis();
|
||||
return Sushi.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
70
SushiBar/SushiBarFileImplement/Models/Component.cs
Normal file
70
SushiBar/SushiBarFileImplement/Models/Component.cs
Normal file
@ -0,0 +1,70 @@
|
||||
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SushiBarFileImplement.Models
|
||||
{
|
||||
internal 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()));
|
||||
}
|
||||
}
|
92
SushiBar/SushiBarFileImplement/Models/Order.cs
Normal file
92
SushiBar/SushiBarFileImplement/Models/Order.cs
Normal file
@ -0,0 +1,92 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Enums;
|
||||
using SushiBarDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SushiBarFileImplement.Models
|
||||
{
|
||||
internal class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int SushiId { 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,
|
||||
SushiId = model.SushiId,
|
||||
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;
|
||||
}
|
||||
string dateImplement = element.Element("DateImplement")!.Value;
|
||||
return new Order()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
SushiId = Convert.ToInt32(element.Element("SushiId")!.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 = (dateImplement == "" || dateImplement is null) ? Convert.ToDateTime(null) : Convert.ToDateTime(dateImplement)
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Status = model.Status;
|
||||
if (model.Status == OrderStatus.Выдан) DateImplement = model.DateImplement;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
SushiId = SushiId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
};
|
||||
|
||||
public XElement GetXElement => new("Order",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("SushiId", SushiId.ToString()),
|
||||
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()));
|
||||
}
|
||||
}
|
112
SushiBar/SushiBarFileImplement/Models/Shop.cs
Normal file
112
SushiBar/SushiBarFileImplement/Models/Shop.cs
Normal file
@ -0,0 +1,112 @@
|
||||
using SushiBarDataModels.Models;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using SushiBarFileImplement;
|
||||
|
||||
namespace SushiBarFileImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ShopName { get; private set; } = string.Empty;
|
||||
public string Adress { get; private set; } = string.Empty;
|
||||
public DateTime OpeningDate { get; private set; }
|
||||
public Dictionary<int, int> Sushis { get; private set; } = new();
|
||||
private Dictionary<int, (ISushiModel, int)>? _shopSushis = null;
|
||||
|
||||
public Dictionary<int, (ISushiModel, int)> ShopSushis
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_shopSushis == null)
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
_shopSushis = Sushis.ToDictionary(x => x.Key, y => ((source.Sushis.FirstOrDefault(z => z.Id == y.Key) as ISushiModel)!, y.Value));
|
||||
}
|
||||
return _shopSushis;
|
||||
}
|
||||
}
|
||||
|
||||
public int SushiMaxCount { get; private set; }
|
||||
|
||||
public static Shop? Create(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Adress = model.Adress,
|
||||
OpeningDate = model.OpeningDate,
|
||||
Sushis = model.ShopSushis.ToDictionary(x => x.Key, x => x.Value.Item2),
|
||||
SushiMaxCount = model.SushiMaxCount
|
||||
};
|
||||
}
|
||||
|
||||
public static Shop? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ShopName = element.Element("ShopName")!.Value,
|
||||
Adress = element.Element("Adress")!.Value,
|
||||
OpeningDate = Convert.ToDateTime(element.Element("OpeningDate")!.Value),
|
||||
Sushis = element.Element("ShopSushis")!.Elements("ShopSushi")!.ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value),
|
||||
x => Convert.ToInt32(x.Element("Value")?.Value)),
|
||||
SushiMaxCount = Convert.ToInt32(element.Element("SushiMaxCount")!.Value)
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ShopName = model.ShopName;
|
||||
Adress = model.Adress;
|
||||
OpeningDate = model.OpeningDate;
|
||||
SushiMaxCount = model.SushiMaxCount;
|
||||
Sushis = model.ShopSushis.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||
_shopSushis = null;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Adress = Adress,
|
||||
OpeningDate = OpeningDate,
|
||||
ShopSushis = ShopSushis,
|
||||
SushiMaxCount = SushiMaxCount
|
||||
};
|
||||
|
||||
public XElement GetXElement => new("Shop",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ShopName", ShopName),
|
||||
new XElement("Adress", Adress),
|
||||
new XElement("OpeningDate", OpeningDate.ToString()),
|
||||
new XElement("ShopSushis", Sushis.Select(
|
||||
x => new XElement("ShopSushi", new XElement("Key", x.Key), new XElement("Value", x.Value))).ToArray()),
|
||||
new XElement("SushiMaxCount", SushiMaxCount.ToString())
|
||||
);
|
||||
|
||||
public void SushisUpdate()
|
||||
{
|
||||
_shopSushis = null;
|
||||
}
|
||||
}
|
||||
}
|
86
SushiBar/SushiBarFileImplement/Models/Sushi.cs
Normal file
86
SushiBar/SushiBarFileImplement/Models/Sushi.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SushiBarFileImplement.Models
|
||||
{
|
||||
public class Sushi : ISushiModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string SushiName { 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)>? _SushiComponents = null;
|
||||
public Dictionary<int, (IComponentModel, int)> SushiComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_SushiComponents == null)
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
_SushiComponents = Components.ToDictionary(x => x.Key, y => ((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!, y.Value));
|
||||
}
|
||||
return _SushiComponents;
|
||||
}
|
||||
}
|
||||
public static Sushi? Create(SushiBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Sushi()
|
||||
{
|
||||
Id = model.Id,
|
||||
SushiName = model.SushiName,
|
||||
Price = model.Price,
|
||||
Components = model.SushiComponents.ToDictionary(x => x.Key, x => x.Value.Item2)
|
||||
};
|
||||
}
|
||||
public static Sushi? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Sushi()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
SushiName = element.Element("SushiName")!.Value,
|
||||
Price = Convert.ToDouble(element.Element("Price")!.Value),
|
||||
Components = element.Element("SushiComponents")!.Elements("SushiComponent").ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value),
|
||||
x => Convert.ToInt32(x.Element("Value")?.Value))
|
||||
};
|
||||
}
|
||||
public void Update(SushiBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SushiName = model.SushiName;
|
||||
Price = model.Price;
|
||||
Components = model.SushiComponents.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||
_SushiComponents = null;
|
||||
}
|
||||
public SushiViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
SushiName = SushiName,
|
||||
Price = Price,
|
||||
SushiComponents = SushiComponents
|
||||
};
|
||||
public XElement GetXElement => new("Sushi",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("SushiName", SushiName),
|
||||
new XElement("Price", Price.ToString()),
|
||||
new XElement("SushiComponents", Components.Select(
|
||||
x => new XElement("SushiComponent", new XElement("Key", x.Key), new XElement("Value", x.Value))).ToArray()));
|
||||
}
|
||||
}
|
14
SushiBar/SushiBarFileImplement/SushiBarFileImplement.csproj
Normal file
14
SushiBar/SushiBarFileImplement/SushiBarFileImplement.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SushiBarContracts\SushiBarContracts.csproj" />
|
||||
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -2,12 +2,12 @@
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SushiBarListImplement.Models;
|
||||
|
||||
namespace SushiBarListImplement.Implements
|
||||
{
|
||||
@ -109,5 +109,15 @@ namespace SushiBarListImplement.Implements
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Sale(SupplySearchModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool RestockingShops(SupplyBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,54 +6,54 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarDataModels.Enums;
|
||||
|
||||
namespace SushiBarListImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ShopName { get; private set; } = string.Empty;
|
||||
public string Adress { get; private set; } = string.Empty;
|
||||
public DateTime OpeningDate { get; private set; }
|
||||
public Dictionary<int, (ISushiModel, int)> ShopSushis { get; private set; } = new();
|
||||
public string ShopName { get; private set; } = string.Empty;
|
||||
public string Adress { get; private set; } = string.Empty;
|
||||
public DateTime OpeningDate { get; private set; }
|
||||
public Dictionary<int, (ISushiModel, int)> ShopSushis { get; private set; } = new();
|
||||
public int SushiMaxCount { get; private set; }
|
||||
|
||||
public static Shop? Create(ShopBindingModel? model)
|
||||
public static Shop? Create(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Adress = model.Adress,
|
||||
OpeningDate = model.OpeningDate
|
||||
};
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Update(ShopBindingModel? model)
|
||||
return new Shop()
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ShopName = model.ShopName;
|
||||
Adress = model.Adress;
|
||||
OpeningDate = model.OpeningDate;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Adress = Adress,
|
||||
OpeningDate = OpeningDate,
|
||||
ShopSushis = ShopSushis
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Adress = model.Adress,
|
||||
OpeningDate = model.OpeningDate,
|
||||
SushiMaxCount = model.SushiMaxCount,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ShopName = model.ShopName;
|
||||
Adress = model.Adress;
|
||||
OpeningDate = model.OpeningDate;
|
||||
SushiMaxCount = model.SushiMaxCount;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Adress = Adress,
|
||||
OpeningDate = OpeningDate,
|
||||
ShopSushis = ShopSushis,
|
||||
SushiMaxCount = SushiMaxCount,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
42
SushiBar/SushiBarView/FormCreateSupply.Designer.cs
generated
42
SushiBar/SushiBarView/FormCreateSupply.Designer.cs
generated
@ -41,62 +41,58 @@
|
||||
// comboBoxShop
|
||||
//
|
||||
this.comboBoxShop.FormattingEnabled = true;
|
||||
this.comboBoxShop.Location = new System.Drawing.Point(101, 9);
|
||||
this.comboBoxShop.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.comboBoxShop.Location = new System.Drawing.Point(115, 12);
|
||||
this.comboBoxShop.Name = "comboBoxShop";
|
||||
this.comboBoxShop.Size = new System.Drawing.Size(302, 23);
|
||||
this.comboBoxShop.Size = new System.Drawing.Size(344, 28);
|
||||
this.comboBoxShop.TabIndex = 0;
|
||||
//
|
||||
// labelShop
|
||||
//
|
||||
this.labelShop.AutoSize = true;
|
||||
this.labelShop.Location = new System.Drawing.Point(10, 11);
|
||||
this.labelShop.Location = new System.Drawing.Point(12, 15);
|
||||
this.labelShop.Name = "labelShop";
|
||||
this.labelShop.Size = new System.Drawing.Size(60, 15);
|
||||
this.labelShop.Size = new System.Drawing.Size(76, 20);
|
||||
this.labelShop.TabIndex = 1;
|
||||
this.labelShop.Text = "Магазин: ";
|
||||
//
|
||||
// labelSushi
|
||||
//
|
||||
this.labelSushi.AutoSize = true;
|
||||
this.labelSushi.Location = new System.Drawing.Point(10, 37);
|
||||
this.labelSushi.Location = new System.Drawing.Point(12, 49);
|
||||
this.labelSushi.Name = "labelSushi";
|
||||
this.labelSushi.Size = new System.Drawing.Size(59, 15);
|
||||
this.labelSushi.Size = new System.Drawing.Size(75, 20);
|
||||
this.labelSushi.TabIndex = 2;
|
||||
this.labelSushi.Text = "Изделие: ";
|
||||
//
|
||||
// comboBoxSushi
|
||||
//
|
||||
this.comboBoxSushi.FormattingEnabled = true;
|
||||
this.comboBoxSushi.Location = new System.Drawing.Point(101, 34);
|
||||
this.comboBoxSushi.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.comboBoxSushi.Location = new System.Drawing.Point(115, 46);
|
||||
this.comboBoxSushi.Name = "comboBoxSushi";
|
||||
this.comboBoxSushi.Size = new System.Drawing.Size(302, 23);
|
||||
this.comboBoxSushi.Size = new System.Drawing.Size(344, 28);
|
||||
this.comboBoxSushi.TabIndex = 3;
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(10, 62);
|
||||
this.labelCount.Location = new System.Drawing.Point(12, 83);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(78, 15);
|
||||
this.labelCount.Size = new System.Drawing.Size(97, 20);
|
||||
this.labelCount.TabIndex = 4;
|
||||
this.labelCount.Text = "Количество: ";
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(101, 60);
|
||||
this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBoxCount.Location = new System.Drawing.Point(115, 80);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(302, 23);
|
||||
this.textBoxCount.Size = new System.Drawing.Size(344, 27);
|
||||
this.textBoxCount.TabIndex = 5;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(262, 85);
|
||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonCancel.Location = new System.Drawing.Point(300, 113);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(102, 29);
|
||||
this.buttonCancel.Size = new System.Drawing.Size(116, 39);
|
||||
this.buttonCancel.TabIndex = 6;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
@ -104,10 +100,9 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(147, 85);
|
||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonSave.Location = new System.Drawing.Point(168, 113);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(102, 29);
|
||||
this.buttonSave.Size = new System.Drawing.Size(116, 39);
|
||||
this.buttonSave.TabIndex = 7;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
@ -115,9 +110,9 @@
|
||||
//
|
||||
// FormCreateSupply
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(412, 123);
|
||||
this.ClientSize = new System.Drawing.Size(471, 164);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
@ -126,7 +121,6 @@
|
||||
this.Controls.Add(this.labelSushi);
|
||||
this.Controls.Add(this.labelShop);
|
||||
this.Controls.Add(this.comboBoxShop);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormCreateSupply";
|
||||
this.Text = "Создание поставки";
|
||||
this.Load += new System.EventHandler(this.FormCreateSupply_Load);
|
||||
|
@ -50,7 +50,7 @@ namespace SushiBarView
|
||||
comboBoxSushi.ValueMember = "Id";
|
||||
comboBoxSushi.DataSource = _sushiList;
|
||||
comboBoxSushi.SelectedItem = null;
|
||||
_logger.LogInformation("Загрузка пиццы для поставок");
|
||||
_logger.LogInformation("Загрузка суши для поставок");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,64 @@
|
||||
<root>
|
||||
<?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">
|
||||
|
53
SushiBar/SushiBarView/FormMain.Designer.cs
generated
53
SushiBar/SushiBarView/FormMain.Designer.cs
generated
@ -36,12 +36,14 @@
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.componentsToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.shopsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.operationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.transactionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.sushiToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.shopsToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.пополнениеМагазинаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.menuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.продажаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ButtonCreateOrder
|
||||
@ -98,7 +100,7 @@
|
||||
//
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripMenuItem1,
|
||||
this.пополнениеМагазинаToolStripMenuItem});
|
||||
this.operationToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(922, 24);
|
||||
@ -110,7 +112,7 @@
|
||||
this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.componentsToolStripMenuItemToolStripMenuItem,
|
||||
this.sushiToolStripMenuItemToolStripMenuItem,
|
||||
this.shopsToolStripMenuItemToolStripMenuItem});
|
||||
this.shopsToolStripMenuItem});
|
||||
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||
this.toolStripMenuItem1.Size = new System.Drawing.Size(94, 20);
|
||||
this.toolStripMenuItem1.Text = "Справочники";
|
||||
@ -129,19 +131,28 @@
|
||||
this.sushiToolStripMenuItemToolStripMenuItem.Text = "Суши";
|
||||
this.sushiToolStripMenuItemToolStripMenuItem.Click += new System.EventHandler(this.sushiToolStripMenuItem_Click);
|
||||
//
|
||||
// shopsToolStripMenuItemToolStripMenuItem
|
||||
// shopsToolStripMenuItem
|
||||
//
|
||||
this.shopsToolStripMenuItemToolStripMenuItem.Name = "shopsToolStripMenuItemToolStripMenuItem";
|
||||
this.shopsToolStripMenuItemToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.shopsToolStripMenuItemToolStripMenuItem.Text = "Магазины";
|
||||
this.shopsToolStripMenuItemToolStripMenuItem.Click += new System.EventHandler(this.shopsToolStripMenuItem_Click);
|
||||
this.shopsToolStripMenuItem.Name = "shopsToolStripMenuItem";
|
||||
this.shopsToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
|
||||
this.shopsToolStripMenuItem.Text = "Магазины";
|
||||
this.shopsToolStripMenuItem.Click += new System.EventHandler(this.shopsToolStripMenuItem_Click);
|
||||
//
|
||||
// пополнениеМагазинаToolStripMenuItem
|
||||
// operationToolStripMenuItem
|
||||
//
|
||||
this.пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem";
|
||||
this.пополнениеМагазинаToolStripMenuItem.Size = new System.Drawing.Size(143, 20);
|
||||
this.пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина";
|
||||
this.пополнениеМагазинаToolStripMenuItem.Click += new System.EventHandler(this.transactionToolStripMenuItem_Click);
|
||||
this.operationToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.transactionToolStripMenuItem,
|
||||
this.продажаToolStripMenuItem});
|
||||
this.operationToolStripMenuItem.Name = "operationToolStripMenuItem";
|
||||
this.operationToolStripMenuItem.Size = new System.Drawing.Size(75, 20);
|
||||
this.operationToolStripMenuItem.Text = "Операции";
|
||||
//
|
||||
// transactionToolStripMenuItem
|
||||
//
|
||||
this.transactionToolStripMenuItem.Name = "transactionToolStripMenuItem";
|
||||
this.transactionToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.transactionToolStripMenuItem.Text = "Поставка";
|
||||
this.transactionToolStripMenuItem.Click += new System.EventHandler(this.transactionToolStripMenuItem_Click);
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
@ -153,6 +164,14 @@
|
||||
this.dataGridView.Size = new System.Drawing.Size(647, 344);
|
||||
this.dataGridView.TabIndex = 6;
|
||||
//
|
||||
// продажаToolStripMenuItem
|
||||
//
|
||||
this.продажаToolStripMenuItem.Name = "продажаToolStripMenuItem";
|
||||
this.продажаToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.продажаToolStripMenuItem.Text = "Продажа";
|
||||
this.продажаToolStripMenuItem.Click += new System.EventHandler(this.SellToolStripMenuItem_Click);
|
||||
//
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
@ -189,7 +208,9 @@
|
||||
private ToolStripMenuItem componentsToolStripMenuItemToolStripMenuItem;
|
||||
private ToolStripMenuItem sushiToolStripMenuItemToolStripMenuItem;
|
||||
private DataGridView dataGridView;
|
||||
private ToolStripMenuItem shopsToolStripMenuItemToolStripMenuItem;
|
||||
private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem;
|
||||
private ToolStripMenuItem shopsToolStripMenuItem;
|
||||
private ToolStripMenuItem operationToolStripMenuItem;
|
||||
private ToolStripMenuItem transactionToolStripMenuItem;
|
||||
private ToolStripMenuItem продажаToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -185,5 +185,13 @@ MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void SellToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSellSushi));
|
||||
if (service is FormSellSushi form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
120
SushiBar/SushiBarView/FormSellSushi.Designer.cs
generated
Normal file
120
SushiBar/SushiBarView/FormSellSushi.Designer.cs
generated
Normal file
@ -0,0 +1,120 @@
|
||||
namespace SushiBarView
|
||||
{
|
||||
partial class FormSellSushi
|
||||
{
|
||||
/// <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.labelSushi = new System.Windows.Forms.Label();
|
||||
this.comboBoxSushi = new System.Windows.Forms.ComboBox();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.buttonSell = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelSushi
|
||||
//
|
||||
this.labelSushi.AutoSize = true;
|
||||
this.labelSushi.Location = new System.Drawing.Point(12, 14);
|
||||
this.labelSushi.Name = "labelSushi";
|
||||
this.labelSushi.Size = new System.Drawing.Size(75, 20);
|
||||
this.labelSushi.TabIndex = 0;
|
||||
this.labelSushi.Text = "Суши: ";
|
||||
//
|
||||
// comboBoxSushi
|
||||
//
|
||||
this.comboBoxSushi.FormattingEnabled = true;
|
||||
this.comboBoxSushi.Location = new System.Drawing.Point(115, 11);
|
||||
this.comboBoxSushi.Name = "comboBoxSushi";
|
||||
this.comboBoxSushi.Size = new System.Drawing.Size(239, 28);
|
||||
this.comboBoxSushi.TabIndex = 1;
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(12, 55);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(97, 20);
|
||||
this.labelCount.TabIndex = 2;
|
||||
this.labelCount.Text = "Количество: ";
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(115, 52);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(239, 27);
|
||||
this.textBoxCount.TabIndex = 3;
|
||||
//
|
||||
// buttonSell
|
||||
//
|
||||
this.buttonSell.Location = new System.Drawing.Point(128, 99);
|
||||
this.buttonSell.Name = "buttonSell";
|
||||
this.buttonSell.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonSell.TabIndex = 4;
|
||||
this.buttonSell.Text = "Продать";
|
||||
this.buttonSell.UseVisualStyleBackColor = true;
|
||||
this.buttonSell.Click += new System.EventHandler(this.ButtonSell_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(242, 99);
|
||||
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);
|
||||
//
|
||||
// FormSellSushi
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(366, 140);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSell);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.comboBoxSushi);
|
||||
this.Controls.Add(this.labelSushi);
|
||||
this.Name = "FormSellSushi";
|
||||
this.Text = "Продажа суши";
|
||||
this.Load += new System.EventHandler(this.FormSellingSushi_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelSushi;
|
||||
private ComboBox comboBoxSushi;
|
||||
private Label labelCount;
|
||||
private TextBox textBoxCount;
|
||||
private Button buttonSell;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
88
SushiBar/SushiBarView/FormSellSushi.cs
Normal file
88
SushiBar/SushiBarView/FormSellSushi.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarContracts.ViewModels;
|
||||
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 SushiBarView
|
||||
{
|
||||
public partial class FormSellSushi : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ISushiLogic _logicP;
|
||||
private readonly IShopLogic _logicS;
|
||||
private List<SushiViewModel> _sushiList = new List<SushiViewModel>();
|
||||
|
||||
public FormSellSushi(ILogger<FormSellSushi> logger, ISushiLogic logicP, IShopLogic logicS)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicP = logicP;
|
||||
_logicS = logicS;
|
||||
}
|
||||
|
||||
private void FormSellingSushi_Load(object sender, EventArgs e)
|
||||
{
|
||||
_sushiList = _logicP.ReadList(null);
|
||||
if (_sushiList != null)
|
||||
{
|
||||
comboBoxSushi.DisplayMember = "SushiName";
|
||||
comboBoxSushi.ValueMember = "Id";
|
||||
comboBoxSushi.DataSource = _sushiList;
|
||||
comboBoxSushi.SelectedItem = null;
|
||||
_logger.LogInformation("Загрузка суши для продажи");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSell_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxSushi.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите суши", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Создание покупки");
|
||||
try
|
||||
{
|
||||
bool resout = _logicS.Sale(new SupplySearchModel
|
||||
{
|
||||
SushiId = Convert.ToInt32(comboBoxSushi.SelectedValue),
|
||||
Count = Convert.ToInt32(textBoxCount.Text)
|
||||
});
|
||||
if (resout)
|
||||
{
|
||||
_logger.LogInformation("Проверка пройдена, продажа проведена");
|
||||
MessageBox.Show("Продажа проведена", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation("Проверка не пройдена");
|
||||
MessageBox.Show("Продажа не может быть создана.", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
120
SushiBar/SushiBarView/FormSellSushi.resx
Normal file
120
SushiBar/SushiBarView/FormSellSushi.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>
|
77
SushiBar/SushiBarView/FormShop.Designer.cs
generated
77
SushiBar/SushiBarView/FormShop.Designer.cs
generated
@ -40,49 +40,49 @@
|
||||
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.dateTimeOpen = new System.Windows.Forms.DateTimePicker();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.numericUpSushiMaxCount = new System.Windows.Forms.NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpSushiMaxCount)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
this.labelName.AutoSize = true;
|
||||
this.labelName.Location = new System.Drawing.Point(10, 11);
|
||||
this.labelName.Location = new System.Drawing.Point(11, 15);
|
||||
this.labelName.Name = "labelName";
|
||||
this.labelName.Size = new System.Drawing.Size(65, 15);
|
||||
this.labelName.Size = new System.Drawing.Size(84, 20);
|
||||
this.labelName.TabIndex = 0;
|
||||
this.labelName.Text = "Название: ";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(89, 9);
|
||||
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBoxName.Location = new System.Drawing.Point(102, 12);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(242, 23);
|
||||
this.textBoxName.Size = new System.Drawing.Size(276, 27);
|
||||
this.textBoxName.TabIndex = 1;
|
||||
//
|
||||
// textBoxAdress
|
||||
//
|
||||
this.textBoxAdress.Location = new System.Drawing.Point(89, 44);
|
||||
this.textBoxAdress.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBoxAdress.Location = new System.Drawing.Point(102, 59);
|
||||
this.textBoxAdress.Name = "textBoxAdress";
|
||||
this.textBoxAdress.Size = new System.Drawing.Size(374, 23);
|
||||
this.textBoxAdress.Size = new System.Drawing.Size(427, 27);
|
||||
this.textBoxAdress.TabIndex = 3;
|
||||
//
|
||||
// labelAdress
|
||||
//
|
||||
this.labelAdress.AutoSize = true;
|
||||
this.labelAdress.Location = new System.Drawing.Point(10, 46);
|
||||
this.labelAdress.Location = new System.Drawing.Point(11, 61);
|
||||
this.labelAdress.Name = "labelAdress";
|
||||
this.labelAdress.Size = new System.Drawing.Size(46, 15);
|
||||
this.labelAdress.Size = new System.Drawing.Size(58, 20);
|
||||
this.labelAdress.TabIndex = 2;
|
||||
this.labelAdress.Text = "Адрес: ";
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(395, 343);
|
||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonCancel.Location = new System.Drawing.Point(451, 457);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(114, 33);
|
||||
this.buttonCancel.Size = new System.Drawing.Size(130, 44);
|
||||
this.buttonCancel.TabIndex = 5;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
@ -90,10 +90,9 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(276, 343);
|
||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonSave.Location = new System.Drawing.Point(315, 457);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(114, 33);
|
||||
this.buttonSave.Size = new System.Drawing.Size(130, 44);
|
||||
this.buttonSave.TabIndex = 6;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
@ -104,20 +103,18 @@
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||
this.dataGridView.BackgroundColor = System.Drawing.Color.White;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.id,
|
||||
this.SushiName,
|
||||
this.Count});
|
||||
this.dataGridView.Location = new System.Drawing.Point(10, 108);
|
||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 185);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.ReadOnly = true;
|
||||
this.dataGridView.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
|
||||
this.dataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(498, 230);
|
||||
this.dataGridView.Size = new System.Drawing.Size(569, 266);
|
||||
this.dataGridView.TabIndex = 7;
|
||||
//
|
||||
// id
|
||||
@ -145,25 +142,47 @@
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(10, 77);
|
||||
this.label1.Location = new System.Drawing.Point(12, 103);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(87, 15);
|
||||
this.label1.Size = new System.Drawing.Size(110, 20);
|
||||
this.label1.TabIndex = 8;
|
||||
this.label1.Text = "Дата открытия";
|
||||
//
|
||||
// dateTimeOpen
|
||||
//
|
||||
this.dateTimeOpen.Location = new System.Drawing.Point(112, 77);
|
||||
this.dateTimeOpen.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.dateTimeOpen.Location = new System.Drawing.Point(128, 103);
|
||||
this.dateTimeOpen.Name = "dateTimeOpen";
|
||||
this.dateTimeOpen.Size = new System.Drawing.Size(351, 23);
|
||||
this.dateTimeOpen.Size = new System.Drawing.Size(401, 27);
|
||||
this.dateTimeOpen.TabIndex = 9;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(12, 148);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(100, 20);
|
||||
this.label2.TabIndex = 10;
|
||||
this.label2.Text = "Вместимость";
|
||||
//
|
||||
// numericUpSushiMaxCount
|
||||
//
|
||||
this.numericUpSushiMaxCount.Location = new System.Drawing.Point(128, 146);
|
||||
this.numericUpSushiMaxCount.Maximum = new decimal(new int[] {
|
||||
10000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpSushiMaxCount.Name = "numericUpSushiMaxCount";
|
||||
this.numericUpSushiMaxCount.Size = new System.Drawing.Size(401, 27);
|
||||
this.numericUpSushiMaxCount.TabIndex = 11;
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(519, 385);
|
||||
this.ClientSize = new System.Drawing.Size(593, 513);
|
||||
this.Controls.Add(this.numericUpSushiMaxCount);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.dateTimeOpen);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
@ -173,11 +192,11 @@
|
||||
this.Controls.Add(this.labelAdress);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.labelName);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormShop";
|
||||
this.Text = "Магазин";
|
||||
this.Load += new System.EventHandler(this.FormShop_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpSushiMaxCount)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -197,5 +216,7 @@
|
||||
private DataGridViewTextBoxColumn Count;
|
||||
private Label label1;
|
||||
private DateTimePicker dateTimeOpen;
|
||||
private Label label2;
|
||||
private NumericUpDown numericUpSushiMaxCount;
|
||||
}
|
||||
}
|
@ -23,7 +23,6 @@ namespace SushiBarView
|
||||
public int Id { set { _id = value; } }
|
||||
private Dictionary<int, (ISushiModel, int)> _ShopSushis;
|
||||
private DateTime? _openingDate = null;
|
||||
|
||||
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -31,7 +30,6 @@ namespace SushiBarView
|
||||
_logic = logic;
|
||||
_ShopSushis = new Dictionary<int, (ISushiModel, int)>();
|
||||
}
|
||||
|
||||
private void FormShop_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
@ -48,6 +46,7 @@ namespace SushiBarView
|
||||
textBoxName.Text = view.ShopName;
|
||||
textBoxAdress.Text = view.Adress;
|
||||
dateTimeOpen.Value = view.OpeningDate;
|
||||
numericUpSushiMaxCount.Value = view.SushiMaxCount;
|
||||
_ShopSushis = view.ShopSushis ?? new Dictionary<int, (ISushiModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
@ -101,7 +100,8 @@ namespace SushiBarView
|
||||
Id = _id ?? 0,
|
||||
ShopName = textBoxName.Text,
|
||||
Adress = textBoxAdress.Text,
|
||||
OpeningDate = dateTimeOpen.Value
|
||||
OpeningDate = dateTimeOpen.Value,
|
||||
SushiMaxCount = (int)numericUpSushiMaxCount.Value
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
@ -118,7 +118,6 @@ namespace SushiBarView
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
|
@ -1,4 +1,64 @@
|
||||
<root>
|
||||
<?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">
|
||||
|
36
SushiBar/SushiBarView/FormShops.Designer.cs
generated
36
SushiBar/SushiBarView/FormShops.Designer.cs
generated
@ -44,18 +44,16 @@
|
||||
this.ToolsPanel.Controls.Add(this.buttonDel);
|
||||
this.ToolsPanel.Controls.Add(this.buttonUpd);
|
||||
this.ToolsPanel.Controls.Add(this.buttonAdd);
|
||||
this.ToolsPanel.Location = new System.Drawing.Point(532, 9);
|
||||
this.ToolsPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.ToolsPanel.Location = new System.Drawing.Point(608, 12);
|
||||
this.ToolsPanel.Name = "ToolsPanel";
|
||||
this.ToolsPanel.Size = new System.Drawing.Size(158, 320);
|
||||
this.ToolsPanel.Size = new System.Drawing.Size(180, 426);
|
||||
this.ToolsPanel.TabIndex = 3;
|
||||
//
|
||||
// buttonRef
|
||||
//
|
||||
this.buttonRef.Location = new System.Drawing.Point(27, 154);
|
||||
this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonRef.Location = new System.Drawing.Point(31, 206);
|
||||
this.buttonRef.Name = "buttonRef";
|
||||
this.buttonRef.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonRef.Size = new System.Drawing.Size(126, 36);
|
||||
this.buttonRef.TabIndex = 3;
|
||||
this.buttonRef.Text = "Обновить";
|
||||
this.buttonRef.UseVisualStyleBackColor = true;
|
||||
@ -63,10 +61,9 @@
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
this.buttonDel.Location = new System.Drawing.Point(27, 106);
|
||||
this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonDel.Location = new System.Drawing.Point(31, 142);
|
||||
this.buttonDel.Name = "buttonDel";
|
||||
this.buttonDel.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonDel.Size = new System.Drawing.Size(126, 36);
|
||||
this.buttonDel.TabIndex = 2;
|
||||
this.buttonDel.Text = "Удалить";
|
||||
this.buttonDel.UseVisualStyleBackColor = true;
|
||||
@ -74,10 +71,9 @@
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
this.buttonUpd.Location = new System.Drawing.Point(27, 57);
|
||||
this.buttonUpd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonUpd.Location = new System.Drawing.Point(31, 76);
|
||||
this.buttonUpd.Name = "buttonUpd";
|
||||
this.buttonUpd.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonUpd.Size = new System.Drawing.Size(126, 36);
|
||||
this.buttonUpd.TabIndex = 1;
|
||||
this.buttonUpd.Text = "Изменить";
|
||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||
@ -85,10 +81,9 @@
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(27, 12);
|
||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonAdd.Location = new System.Drawing.Point(31, 16);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonAdd.Size = new System.Drawing.Size(126, 36);
|
||||
this.buttonAdd.TabIndex = 0;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
@ -98,25 +93,22 @@
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.BackgroundColor = System.Drawing.Color.White;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(10, 9);
|
||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.ReadOnly = true;
|
||||
this.dataGridView.RowHeadersWidth = 51;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(516, 320);
|
||||
this.dataGridView.Size = new System.Drawing.Size(590, 426);
|
||||
this.dataGridView.TabIndex = 2;
|
||||
//
|
||||
// FormShops
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(700, 338);
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.ToolsPanel);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormShops";
|
||||
this.Text = "Магазины";
|
||||
this.Load += new System.EventHandler(this.FormShops_Load);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using System;
|
||||
|
@ -1,4 +1,64 @@
|
||||
<root>
|
||||
<?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">
|
||||
|
@ -3,12 +3,11 @@ using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using System;
|
||||
using SushiBarBusinessLogic.BusinessLogics;
|
||||
using SushiBarListImplement.Implements;
|
||||
using SushiBarFileImplement.Implements;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarView;
|
||||
using NLog.Extensions.Logging;
|
||||
|
||||
|
||||
namespace SushiBarView
|
||||
{
|
||||
internal static class Program
|
||||
@ -47,12 +46,12 @@ namespace SushiBarView
|
||||
services.AddTransient<FormSushis>();
|
||||
services.AddTransient<FormSushiComponent>();
|
||||
services.AddTransient<FormSushi>();
|
||||
|
||||
services.AddTransient<IShopStorage, ShopStorage>();
|
||||
services.AddTransient<IShopLogic, ShopLogic>();
|
||||
services.AddTransient<FormShop>();
|
||||
services.AddTransient<FormShops>();
|
||||
services.AddTransient<FormCreateSupply>();
|
||||
services.AddTransient<FormSellSushi>();
|
||||
}
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SushiBarBusinessLogic_\SushiBarBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\SushiBarContracts\SushiBarContracts.csproj" />
|
||||
<ProjectReference Include="..\SushiBarFileImplement\SushiBarFileImplement.csproj" />
|
||||
<ProjectReference Include="..\SushiBarListImplement_\SushiBarListImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user