Borschevskaya A.A. Lab Work 2 Hard #4

Closed
pgirl1 wants to merge 17 commits from lab2_hard into lab1_hard
2 changed files with 14 additions and 15 deletions
Showing only changes of commit 0ff31eeb2a - Show all commits

View File

@ -108,12 +108,7 @@ namespace FurnitureAssembly
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
int furnitureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["FurnitureId"].Value);
int furnitureCount = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value);
if (!_shopLogic.AddFurnituresAtShops(new FurnitureBindingModel { Id = furnitureId }, furnitureCount)) {
MessageBox.Show("Магазины переполнены. Пополнение невозможно", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
@ -121,11 +116,7 @@ namespace FurnitureAssembly
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
@ -142,8 +133,7 @@ namespace FurnitureAssembly
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'",
id);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
try
{
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });

View File

@ -17,11 +17,13 @@ namespace FurnitureAssemblyBusinessLogic
{
private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage;
private readonly IShopLogic _shopLogic;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopLogic shopLogic)
{
_logger = logger;
_orderStorage = orderStorage;
_shopLogic = shopLogic;
}
private bool ChangeStatus(OrderBindingModel model, OrderStatus orderStatus)
@ -91,6 +93,13 @@ namespace FurnitureAssemblyBusinessLogic
{
return false;
}
if (!_shopLogic.AddFurnituresAtShops(new FurnitureBindingModel() { Id = model.FurnitureId}, model.Count))
{
_logger.LogWarning("There are not empty places at shops. Replenishment is impossible");
return false;
}
if (!ChangeStatus(model, OrderStatus.Выдан))
{
_logger.LogWarning("Order's status is wrong");
@ -101,7 +110,7 @@ namespace FurnitureAssemblyBusinessLogic
return true;
}
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
{
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);