Eliseev E.E. LabWork01 #1
@ -99,12 +99,7 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].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())
|
||||
Id = id
|
||||
});
|
||||
|
||||
if (!operationResult)
|
||||
@ -133,12 +128,7 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].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())
|
||||
Id = id
|
||||
});
|
||||
|
||||
if (!operationResult)
|
||||
@ -167,12 +157,7 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].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())
|
||||
Id = id
|
||||
});
|
||||
|
||||
if (!operationResult)
|
||||
|
@ -128,10 +128,16 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
//обновление статуса заказа
|
||||
public bool StatusUpdate(OrderBindingModel model, OrderStatus newOrderStatus)
|
||||
{
|
||||
CheckModel(model);
|
||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
|
||||
//если не смогли найти указанный заказ по его Id
|
||||
if(viewModel == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
//проверка на возможность обновления статуса на следующий
|
||||
if(model.Status + 1 != newOrderStatus)
|
||||
if (viewModel.Status + 1 != newOrderStatus)
|
||||
{
|
||||
_logger.LogWarning("Status update operation failed. New status " + newOrderStatus.ToString() + " incorrect");
|
||||
return false;
|
||||
@ -144,9 +150,15 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
{
|
||||
model.DateImplement = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
model.DateImplement = viewModel.DateImplement;
|
||||
}
|
||||
|
||||
CheckModel(model, false);
|
||||
|
||||
//финальная проверка на возможность обновления
|
||||
if(_orderStorage.Update(model) == null)
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
model.Status--;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user