Лабораторная 1. Исправления
This commit is contained in:
parent
d627ca6623
commit
3155cd0b0d
@ -79,15 +79,7 @@ namespace FlowerShop
|
||||
_logger.LogInformation("Order №{id}. Changing status to 'Processing'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
BouquetId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["BouquetId"].Value),
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
});
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
@ -114,19 +106,11 @@ namespace FlowerShop
|
||||
_logger.LogInformation("Order №{id}. Changing status to 'Ready'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
BouquetId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["BouquetId"].Value),
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
});
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
|
||||
if (!operationResult)
|
||||
{
|
||||
_logger.LogError("Error during changing order's status to 'Ready'");
|
||||
MessageBox.Show("Заказ должен быть в состоянии 'В работе'", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("Заказ должен быть в состоянии 'Выполняется'", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
@ -147,16 +131,7 @@ namespace FlowerShop
|
||||
_logger.LogInformation("Order №{id}. Changing status to 'Delivered'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(new
|
||||
OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
BouquetId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["BouquetId"].Value),
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
});
|
||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
@ -169,8 +144,7 @@ namespace FlowerShop
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error during changing order's status to 'Delivered'");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ namespace FlowerShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
if (model.Status != OrderStatus.Принят)
|
||||
if (_orderStorage.GetElement(new OrderSearchModel { Id=model.Id })?.Status != OrderStatus.Принят)
|
||||
{
|
||||
_logger.LogWarning("Invalid order status");
|
||||
return false;
|
||||
@ -78,13 +78,14 @@ namespace FlowerShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
if (model.Status != OrderStatus.Выполняется)
|
||||
if (_orderStorage.GetElement(new OrderSearchModel { Id = model.Id })?.Status != OrderStatus.Выполняется)
|
||||
{
|
||||
_logger.LogWarning("Invalid order status");
|
||||
return false;
|
||||
}
|
||||
|
||||
model.Status = OrderStatus.Готов;
|
||||
model.DateImplement = DateTime.Now;
|
||||
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
@ -98,14 +99,16 @@ namespace FlowerShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
if (model.Status != OrderStatus.Готов)
|
||||
var order = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
|
||||
if (order?.Status != OrderStatus.Готов)
|
||||
{
|
||||
_logger.LogWarning("Invalid order status");
|
||||
return false;
|
||||
}
|
||||
|
||||
model.Status = OrderStatus.Выдан;
|
||||
model.DateImplement = DateTime.Now;
|
||||
model.DateImplement = order.DateImplement;
|
||||
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user