ISEbd-21.Fedotov.I.A.LabWork02 #2

Closed
Ilfedotov.01 wants to merge 5 commits from ISEbd-21.Fedotov.I.A.LabWork02 into ISEbd-21.Fedotov.I.A.LabWork01
19 changed files with 571 additions and 37 deletions

View File

@ -5,13 +5,15 @@ VisualStudioVersion = 17.7.34221.43
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DinerView", "DinerView\DinerView.csproj", "{7FC291E6-FE0A-4D25-B46F-724FB599F26F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DinerDataModels", "DinerDataModels\DinerDataModels.csproj", "{2AFAC265-13C0-432E-8F33-ABF764FD0877}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DinerDataModels", "DinerDataModels\DinerDataModels.csproj", "{2AFAC265-13C0-432E-8F33-ABF764FD0877}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DinerContracts", "DinerContracts\DinerContracts.csproj", "{89BA6B4F-1F08-4327-B88B-E48335742088}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DinerContracts", "DinerContracts\DinerContracts.csproj", "{89BA6B4F-1F08-4327-B88B-E48335742088}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DinerListImplement", "DinerListImplement\DinerListImplement.csproj", "{33BCF269-AF60-4E7E-9F3B-2ECEDCEBF8F9}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DinerListImplement", "DinerListImplement\DinerListImplement.csproj", "{33BCF269-AF60-4E7E-9F3B-2ECEDCEBF8F9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DineryBusinessLogic", "DineryBusinessLogic\DineryBusinessLogic.csproj", "{2920D9E3-AE18-4914-BD43-C04D9123FBD7}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DineryBusinessLogic", "DineryBusinessLogic\DineryBusinessLogic.csproj", "{2920D9E3-AE18-4914-BD43-C04D9123FBD7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DinerFileImplement", "DinerShopImplement\DinerFileImplement.csproj", "{E46007E3-F3EC-4551-A203-19361E7B1B8D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -39,6 +41,10 @@ Global
{2920D9E3-AE18-4914-BD43-C04D9123FBD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2920D9E3-AE18-4914-BD43-C04D9123FBD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2920D9E3-AE18-4914-BD43-C04D9123FBD7}.Release|Any CPU.Build.0 = Release|Any CPU
{E46007E3-F3EC-4551-A203-19361E7B1B8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E46007E3-F3EC-4551-A203-19361E7B1B8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E46007E3-F3EC-4551-A203-19361E7B1B8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E46007E3-F3EC-4551-A203-19361E7B1B8D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,59 @@
using DinerFileImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace DinerFileImplement
{
internal class DataFileSingleton
{
private static DataFileSingleton? instance;
private readonly string FoodFileName = "Food.xml";
private readonly string OrderFileName = "Order.xml";
private readonly string SnackFileName = "Snack.xml";
public List<Food> Foods { get; set; }
public List<Order> Orders { get; private set; }
public List<Snack> Snacks { get; private set; }
private DataFileSingleton() {
Foods = LoadData(FoodFileName, "Food", x => Food.Create(x)!)!;
Snacks = LoadData(SnackFileName, "Snack", x => Snack.Create(x)!)!;
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
}
public static DataFileSingleton GetInstance() {
if (instance == null) instance = new DataFileSingleton();
return instance;
}
public void SaveFoods() => SaveData(Foods, FoodFileName, "Foods",
x => x.GetXElement);
public void SaveSnacks() => SaveData(Snacks, SnackFileName, "Snacks",
x => x.GetXElement);
public void SaveOrder() => SaveData(Orders, OrderFileName, "Orders",
x => x.GetXElement);
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);
}
}
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>();
}
}
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DinerContracts\DinerContracts.csproj" />
<ProjectReference Include="..\DinerDataModels\DinerDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,75 @@
using DinerContracts.BindingModels;
using DinerContracts.SearchModels;
using DinerContracts.StoragesContracts;
using DinerContracts.ViewModels;
using DinerFileImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DinerFileImplement.Implements
{
public class FoodStorage : IFoodStorage
{
private readonly DataFileSingleton _source;
public FoodStorage()
{
_source = DataFileSingleton.GetInstance();
}
public FoodViewModel? Delete(FoodBindingModel model)
{
var element = _source.Foods.FirstOrDefault(x => x.ID == model.ID);
if (element != null) {
_source.Foods.Remove(element);
_source.SaveFoods();
return element.GetViewModel;
}
return null;
}
public FoodViewModel? GetElement(FoodSearchModel model)
{
if (string.IsNullOrEmpty(model.ComponentName) && !model.ID.HasValue) { return null; }
return _source.Foods
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName) &&
x.ComponentName == model.ComponentName) || model.ID.HasValue &&
x.ID == model.ID)?.GetViewModel;
}
public List<FoodViewModel> GetFilteredList(FoodSearchModel model)
{
if (string.IsNullOrEmpty(model.ComponentName)) { return new(); }
return _source.Foods.Where(x => x.ComponentName.Contains(model.ComponentName))
.Select(x => x.GetViewModel).ToList();
}
public List<FoodViewModel> GetFullList()
{
return _source.Foods.Select(x => x.GetViewModel).ToList();
}
public FoodViewModel? Insert(FoodBindingModel model)
{
model.ID = _source.Foods.Count > 0 ? _source.Foods.Max(x => x.ID) + 1 : 1;
var newComponent = Food.Create(model);
if (newComponent == null) { return null; }
_source.Foods.Add(newComponent);
_source.SaveFoods();
return newComponent.GetViewModel;
}
public FoodViewModel? Update(FoodBindingModel model)
{
var component = _source.Foods.FirstOrDefault(x => x.ID == model.ID);
if (component == null) { return null; }
component.Update(model);
_source.SaveFoods();
return component.GetViewModel;
}
}
}

View File

@ -0,0 +1,81 @@
using DinerContracts.BindingModels;
using DinerContracts.SearchModels;
using DinerContracts.StoragesContracts;
using DinerContracts.ViewModels;
using DinerFileImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace DinerFileImplement.Implements
{
public class OrderStorage : IOrderStorage
{
private readonly DataFileSingleton _source;
public OrderStorage()
{
_source = DataFileSingleton.GetInstance();
}
public OrderViewModel? Delete(OrderBindingModel model)
{
var element = _source.Orders.FirstOrDefault(x => x.ID == model.ID);
if (element != null) {
_source.Orders.Remove(element);
_source.SaveOrder();
return GetViewModel(element);
}
return null;
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
if (!model.ID.HasValue) { return null; }
return _source.Orders
.FirstOrDefault(x => model.ID.HasValue && x.ID == model.ID)?.GetViewModel;
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.ID.HasValue) { return new(); }
return _source.Orders.Where(x => x.ID == model.ID).Select(GetViewModel).ToList();
}
public List<OrderViewModel> GetFullList()
{
return _source.Orders.Select(GetViewModel).ToList();
}
private OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
var tmp = from p in _source.Snacks
where p.ID == order.ProductID
select p.ProductName;
viewModel.ProductName = tmp.FirstOrDefault(string.Empty);
return viewModel;
}
public OrderViewModel? Insert(OrderBindingModel model)
{
model.ID = _source.Orders.Count > 0 ? _source.Orders.Max(x => x.ID) + 1 : 1;
var newOrder = Order.Create(model);
if (newOrder == null) { return null; }
_source.Orders.Add(newOrder);
_source.SaveOrder();
return GetViewModel(newOrder);
}
public OrderViewModel? Update(OrderBindingModel model)
{
var order = _source.Orders.FirstOrDefault(x => x.ID == model.ID);
if (order == null) { return null; }
order.Update(model);
_source.SaveOrder();
return GetViewModel(order);
}
}
}

View File

@ -0,0 +1,74 @@
using DinerContracts.BindingModels;
using DinerContracts.SearchModels;
using DinerContracts.StoragesContracts;
using DinerContracts.ViewModels;
using DinerFileImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DinerFileImplement.Implements
{
public class SnackStorage : ISnackStorage
{
private readonly DataFileSingleton _source;
public SnackStorage()
{
_source = DataFileSingleton.GetInstance();
}
public SnackViewModel? Delete(SnackBindingModel model)
{
var element = _source.Snacks.FirstOrDefault(x => x.ID == model.ID);
if (element != null) {
_source.Snacks.Remove(element);
_source.SaveSnacks();
return element.GetViewModel;
}
return null;
}
public SnackViewModel? GetElement(SnackSearchModel model)
{
if (string.IsNullOrEmpty(model.ProductName) && !model.ID.HasValue) { return null; }
return _source.Snacks
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ProductName) &&
x.ProductName == model.ProductName) || model.ID.HasValue &&
x.ID == model.ID)?.GetViewModel;
}
public List<SnackViewModel> GetFilteredList(SnackSearchModel model)
{
if (string.IsNullOrEmpty(model.ProductName)) { return new(); }
return _source.Snacks.Where(x => x.ProductName.Contains(model.ProductName))
.Select(x => x.GetViewModel).ToList();
}
public List<SnackViewModel> GetFullList()
{
return _source.Snacks.Select(x => x.GetViewModel).ToList();
}
public SnackViewModel? Insert(SnackBindingModel model)
{
model.ID = _source.Snacks.Count > 0 ? _source.Snacks.Max(x => x.ID) + 1 : 1;
var newProduct = Snack.Create(model);
if (newProduct == null) { return null; }
_source.Snacks.Add(newProduct);
_source.SaveSnacks();
return newProduct.GetViewModel;
}
public SnackViewModel? Update(SnackBindingModel model)
{
var product = _source.Snacks.FirstOrDefault(x => x.ID == model.ID);
if (product == null) { return null; }
product.Update(model);
_source.SaveSnacks();
return product.GetViewModel;
}
}
}

View File

@ -0,0 +1,57 @@
using DinerContracts.BindingModels;
using DinerContracts.ViewModels;
using DinerDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace DinerFileImplement.Models
{
internal class Food : IFoodModel
{
public string ComponentName { get; set; } = string.Empty;
public double Price { get; set; }
public int ID { get; set; }
public static Food? Create(FoodBindingModel? model)
{
if (model == null) return null;
return new Food()
{
ID = model.ID,
ComponentName = model.ComponentName,
Price = model.Price,
};
}
public static Food? Create(XElement element) {
if (element == null) return null;
return new Food()
{
ID = Convert.ToInt32(element.Attribute("ID")!.Value),
ComponentName = element.Element("ComponentName")!.Value,
Price = Convert.ToDouble(element.Element("Price")!.Value)
};
}
public void Update(FoodBindingModel? model)
{
if (model == null) return;
ComponentName = model.ComponentName;
Price = model.Price;
}
public FoodViewModel GetViewModel => new()
{
ID = ID,
ComponentName = ComponentName,
Price = Price,
};
public XElement GetXElement => new("Food", new XAttribute("ID", ID),
new XElement("ComponentName", ComponentName),
new XElement("Price", Price.ToString()));
}
}

View File

@ -0,0 +1,84 @@
using DinerContracts.BindingModels;
using DinerContracts.ViewModels;
using DinerDataModels.Enums;
using DinerDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace DinerFileImplement.Models
{
internal class Order : IOrderModel
{
public int ProductID { get; private set; }
public int Count { get; set; }
public double Sum { get; private set; }
public OrderStatus Status { get; set; }
public DateTime DateCreate { get; private set; }
public DateTime? DateImplement { get; set; }
public int ID { get; private set; }
public static Order? Create(OrderBindingModel? model)
{
if (model == null) return null;
return new Order()
{
ID = model.ID,
ProductID = model.ProductID,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement,
};
}
public static Order? Create(XElement element) {
if (element == null) return null;
return new Order()
{
ID = Convert.ToInt32(element.Attribute("ID")!.Value),
ProductID = Convert.ToInt32(element.Element("ProductID")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null :
Convert.ToDateTime(element.Element("DateImplement")!.Value),
};
}
public void Update(OrderBindingModel? model)
{
if (model == null) return;
Status = model.Status;
DateImplement = model?.DateImplement;
}
public OrderViewModel GetViewModel => new()
{
ID = ID,
ProductID = ProductID,
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement,
};
public XElement GetXElement => new("Order", new XAttribute("ID", ID),
new XElement("ProductID", ProductID),
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()));
}
}

View File

@ -0,0 +1,83 @@
using DinerContracts.BindingModels;
using DinerContracts.ViewModels;
using DinerDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Xml.XPath;
namespace DinerFileImplement.Models
{
internal class Snack : ISnackModel
{
public string ProductName { get; private set; } = string.Empty;
public double Price { get; private set; }
public int ID { get; private set; }
public Dictionary<int, int> Components { get; private set; } = new();
private Dictionary<int, (IFoodModel, int)>? _productComponents = null;
public Dictionary<int, (IFoodModel, int)> ProductComponents
{
get
{
if (_productComponents == null) {
var source = DataFileSingleton.GetInstance();
_productComponents = Components.ToDictionary(x => x.Key, y => ((source.Foods.FirstOrDefault(z => z.ID ==
y.Key) as IFoodModel)!, y.Value));
}
return _productComponents;
}
}
public static Snack? Create(SnackBindingModel? model)
{
if (model == null) return null;
return new Snack()
{
ID = model.ID,
ProductName = model.ProductName,
Price = model.Price,
Components = model.ProductComponents.ToDictionary(x => x.Key, x => x.Value.Item2)
};
}
public static Snack? Create(XElement element)
{
if (element == null) return null;
return new Snack()
{
ID = Convert.ToInt32(element.Attribute("ID")!.Value),
ProductName = element.Element("ProductName")!.Value,
Price = Convert.ToDouble(element.Element("Price")!.Value),
Components = element.Element("ProductComponents")!.Elements("ProductComponent")
.ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
};
}
public void Update(SnackBindingModel? model)
{
if (model == null) return;
ProductName = model.ProductName;
Price = model.Price;
Components = model.ProductComponents.ToDictionary(x => x.Key, x => x.Value.Item2);
_productComponents = null;
}
public SnackViewModel GetViewModel => new()
{
ID = ID,
ProductName = ProductName,
Price = Price,
ProductComponents = ProductComponents
};
public XElement GetXElement => new("Snack", new XAttribute("ID", ID),
new XElement("ProductName", ProductName),
new XElement("Price", Price.ToString()),
new XElement("ProductComponents", Components.Select(x => new XElement("ProductComponent",
new XElement("Key", x.Key),
new XElement("Value", x.Value))).ToArray()));
}
}

View File

@ -27,7 +27,7 @@
<ItemGroup>
<ProjectReference Include="..\DinerContracts\DinerContracts.csproj" />
<ProjectReference Include="..\DinerListImplement\DinerListImplement.csproj" />
<ProjectReference Include="..\DinerShopImplement\DinerFileImplement.csproj" />
<ProjectReference Include="..\DineryBusinessLogic\DineryBusinessLogic.csproj" />
</ItemGroup>

View File

@ -100,7 +100,7 @@
Controls.Add(labelPrice);
Controls.Add(labelName);
Name = "FormFood";
Text = "Food";
Text = "Продукт питания";
Load += FormComponent_Load;
ResumeLayout(false);
PerformLayout();

View File

@ -105,7 +105,7 @@
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormFoods";
Text = "Foods";
Text = "Продукты";
Load += FormComponents_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);

View File

@ -62,14 +62,14 @@
// toolStripMenuItemFoods
//
toolStripMenuItemFoods.Name = "toolStripMenuItemFoods";
toolStripMenuItemFoods.Size = new Size(129, 22);
toolStripMenuItemFoods.Size = new Size(180, 22);
toolStripMenuItemFoods.Text = "Продукты";
toolStripMenuItemFoods.Click += toolStripMenuItemFoods_Click;
//
// toolStripMenuItemSnacks
//
toolStripMenuItemSnacks.Name = "toolStripMenuItemSnacks";
toolStripMenuItemSnacks.Size = new Size(129, 22);
toolStripMenuItemSnacks.Size = new Size(180, 22);
toolStripMenuItemSnacks.Text = "Снэки";
toolStripMenuItemSnacks.Click += toolStripMenuItemSnacks_Click;
//
@ -155,7 +155,7 @@
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormMain";
Text = "FormMain";
Text = "Заказы";
Load += FormMain_Load;
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();

View File

@ -40,6 +40,7 @@ namespace DinerView
{
dataGridView.DataSource = list;
dataGridView.Columns["ProductID"].Visible = false;
dataGridView.Columns["Sum"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка заказов");
}

View File

@ -38,11 +38,11 @@
buttonChange = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
buttonCancel = new Button();
buttonSave = new Button();
ColumnID = new DataGridViewTextBoxColumn();
ColumnFood = new DataGridViewTextBoxColumn();
ColumnCount = new DataGridViewTextBoxColumn();
buttonCancel = new Button();
buttonSave = new Button();
groupBoxFoods.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
@ -160,26 +160,6 @@
dataGridView.Size = new Size(437, 351);
dataGridView.TabIndex = 0;
//
// buttonCancel
//
buttonCancel.Location = new Point(587, 30);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(82, 27);
buttonCancel.TabIndex = 5;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(499, 30);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(82, 27);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// ColumnID
//
ColumnID.HeaderText = "ID";
@ -200,6 +180,26 @@
ColumnCount.Name = "ColumnCount";
ColumnCount.ReadOnly = true;
//
// buttonCancel
//
buttonCancel.Location = new Point(587, 30);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(82, 27);
buttonCancel.TabIndex = 5;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(499, 30);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(82, 27);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// FormSnack
//
AutoScaleDimensions = new SizeF(7F, 15F);
@ -213,7 +213,7 @@
Controls.Add(labelPrice);
Controls.Add(labelName);
Name = "FormSnack";
Text = "Snack";
Text = "Снэки";
Load += FormSnack_Load;
groupBoxFoods.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();

View File

@ -103,7 +103,7 @@
Controls.Add(labelCount);
Controls.Add(labelComponent);
Name = "FormSnackFood";
Text = "Snack food";
Text = "Продукты для снэков";
ResumeLayout(false);
PerformLayout();
}

View File

@ -105,7 +105,7 @@
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormSnacks";
Text = "FormSnacks";
Text = "Снэки";
Load += FormSnacks_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);

View File

@ -1,6 +1,6 @@
using DinerContracts.BusinessLogicsContacts;
using DinerContracts.StoragesContracts;
using DinerListImplement.Implements;
using DinerFileImplement.Implements;
using DineryBusinessLogic.BusinessLogic;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

View File

@ -86,7 +86,7 @@ namespace DineryBusinessLogic.BusinessLogic
if (model.Price <= 0)
throw new ArgumentNullException("Цена продукта должна быть больше 0", nameof(model.Price));
_logger.LogInformation("Product. ProductName:{ProductName}. Price:{Price}. ID:{ID}",
model.ProductName, model.Price, model.Price);
model.ProductName, model.Price, model.ID);
var element = _productStorage.GetElement(new SnackSearchModel { ProductName = model.ProductName });
if (element != null && element.ID != model.ID)
throw new InvalidOperationException("Продукт с таким названием уже есть");