Merge branch 'lab2_hard' into lab3_hard
This commit is contained in:
commit
e3958cfb54
@ -124,6 +124,7 @@ namespace FurnitureAssemFileImplement.Implements
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
count -= shop.Furnitures[furniture.Id].Item2;
|
||||||
shop.Furnitures[furniture.Id] = (shop.Furnitures[furniture.Id].Item1, 0);
|
shop.Furnitures[furniture.Id] = (shop.Furnitures[furniture.Id].Item1, 0);
|
||||||
shop.Update(new ShopBindingModel
|
shop.Update(new ShopBindingModel
|
||||||
{
|
{
|
||||||
@ -134,7 +135,7 @@ namespace FurnitureAssemFileImplement.Implements
|
|||||||
Address = shop.Address,
|
Address = shop.Address,
|
||||||
DateOpening = shop.DateOpening,
|
DateOpening = shop.DateOpening,
|
||||||
});
|
});
|
||||||
count -= shop.Furnitures[furniture.Id].Item2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
source.SaveShops();
|
source.SaveShops();
|
||||||
|
@ -181,30 +181,7 @@ namespace FurnitureAssembly
|
|||||||
var service = Program.ServiceProvider?.GetService(typeof(FormReplenishmentShop));
|
var service = Program.ServiceProvider?.GetService(typeof(FormReplenishmentShop));
|
||||||
if (service is FormReplenishmentShop form)
|
if (service is FormReplenishmentShop form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
form.ShowDialog();
|
||||||
{
|
|
||||||
if (form.ShopModel == null || form.FurnitureModel == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Добавление в магазин {ShopName} изделия: { FurnitureName}- { Count}", form.ShopModel.ShopName, form.FurnitureModel.FurnitureName, form.Count);
|
|
||||||
|
|
||||||
var modelShop = new ShopBindingModel
|
|
||||||
{
|
|
||||||
Id = form.Id
|
|
||||||
};
|
|
||||||
|
|
||||||
var modelFurn = new FurnitureBindingModel
|
|
||||||
{
|
|
||||||
Id = form.FurnitureId
|
|
||||||
};
|
|
||||||
|
|
||||||
var operationResult = _shopLogic.AddFurniture(modelShop, modelFurn, form.Count);
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при пополнении магазина. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using FurnitureAssemblyContracts.BusinessLogicsContarcts;
|
using FurnitureAssemblyContracts.BusinessLogicsContarcts;
|
||||||
using FurnitureAssemblyContracts.ViewModels;
|
using FurnitureAssemblyContracts.ViewModels;
|
||||||
using FurnitureAssemblyDataModels.Models;
|
using FurnitureAssemblyDataModels.Models;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -21,6 +22,9 @@ namespace FurnitureAssembly
|
|||||||
private readonly List<ShopViewModel>? _listShops;
|
private readonly List<ShopViewModel>? _listShops;
|
||||||
private readonly List<FurnitureViewModel>? _listFurnitures;
|
private readonly List<FurnitureViewModel>? _listFurnitures;
|
||||||
|
|
||||||
|
private IShopLogic _shopLogic;
|
||||||
|
private ILogger _logger;
|
||||||
|
|
||||||
public int Id
|
public int Id
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -32,24 +36,6 @@ namespace FurnitureAssembly
|
|||||||
comboBoxShop.SelectedValue = value;
|
comboBoxShop.SelectedValue = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public IShopModel? ShopModel
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_listShops == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var elem in _listShops)
|
|
||||||
{
|
|
||||||
if (elem.Id == Id)
|
|
||||||
{
|
|
||||||
return elem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int FurnitureId
|
public int FurnitureId
|
||||||
{
|
{
|
||||||
@ -62,24 +48,6 @@ namespace FurnitureAssembly
|
|||||||
comboBoxFurniture.SelectedValue = value;
|
comboBoxFurniture.SelectedValue = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public IFurnitureModel? FurnitureModel
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_listFurnitures == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var elem in _listFurnitures)
|
|
||||||
{
|
|
||||||
if (elem.Id == Id)
|
|
||||||
{
|
|
||||||
return elem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Count
|
public int Count
|
||||||
{
|
{
|
||||||
@ -87,9 +55,11 @@ namespace FurnitureAssembly
|
|||||||
set
|
set
|
||||||
{ textBoxCount.Text = value.ToString(); }
|
{ textBoxCount.Text = value.ToString(); }
|
||||||
}
|
}
|
||||||
public FormReplenishmentShop(IShopLogic shopLogic, IFurnitureLogic furnitureLogic)
|
public FormReplenishmentShop(ILogger<FormReplenishmentShop> logger, IShopLogic shopLogic, IFurnitureLogic furnitureLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_shopLogic = shopLogic;
|
||||||
_listShops = shopLogic.ReadList(null);
|
_listShops = shopLogic.ReadList(null);
|
||||||
_listFurnitures = furnitureLogic.ReadList(null);
|
_listFurnitures = furnitureLogic.ReadList(null);
|
||||||
if (_listShops != null)
|
if (_listShops != null)
|
||||||
@ -135,6 +105,22 @@ namespace FurnitureAssembly
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление в магазин с id = {ShopName} изделия: id = { FurnitureName} - { Count}", Id, FurnitureId, Count);
|
||||||
|
var operationResult = _shopLogic.AddFurniture(new ShopBindingModel { Id = Id }, new FurnitureBindingModel { Id = FurnitureId }, Count);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при пополнении магазина. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при пополнении магазина c id = " + Id);
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,7 @@ namespace FurnitureAssembly
|
|||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось продать изделие " + FurnitureModel.FurnitureName, "Ошибка",
|
MessageBox.Show("Не удалось продать изделие " + FurnitureModel.FurnitureName, "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
MessageBox.Show("Продажа прошла успешно", "Сообщение",
|
MessageBox.Show("Продажа прошла успешно", "Сообщение",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
@ -154,9 +154,9 @@
|
|||||||
this.labelMaxCount.AutoSize = true;
|
this.labelMaxCount.AutoSize = true;
|
||||||
this.labelMaxCount.Location = new System.Drawing.Point(35, 141);
|
this.labelMaxCount.Location = new System.Drawing.Point(35, 141);
|
||||||
this.labelMaxCount.Name = "labelMaxCount";
|
this.labelMaxCount.Name = "labelMaxCount";
|
||||||
this.labelMaxCount.Size = new System.Drawing.Size(40, 15);
|
this.labelMaxCount.Size = new System.Drawing.Size(80, 15);
|
||||||
this.labelMaxCount.TabIndex = 10;
|
this.labelMaxCount.TabIndex = 10;
|
||||||
this.labelMaxCount.Text = "Адрес";
|
this.labelMaxCount.Text = "Вместимость";
|
||||||
//
|
//
|
||||||
// FormShop
|
// FormShop
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user