Исправление
This commit is contained in:
parent
7cc7439f3d
commit
c3d8dfd646
@ -84,7 +84,7 @@ namespace FurnitureAssembly
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(GetOrderBindingModel());
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
@ -109,7 +109,7 @@ namespace FurnitureAssembly
|
||||
id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(GetOrderBindingModel());
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
@ -134,7 +134,7 @@ namespace FurnitureAssembly
|
||||
id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(GetOrderBindingModel());
|
||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
@ -154,19 +154,5 @@ namespace FurnitureAssembly
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private OrderBindingModel GetOrderBindingModel()
|
||||
{
|
||||
return new OrderBindingModel
|
||||
{
|
||||
Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value),
|
||||
FurnitureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["FurnitureId"].Value),
|
||||
FurnitureName = dataGridView.SelectedRows[0].Cells["FurnitureName"].Value.ToString(),
|
||||
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())
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,11 @@ namespace FurnitureAssemblyBusinessLogic
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
model = Find(model);
|
||||
if (model == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!ChangeStatus(model, OrderStatus.Выполняется))
|
||||
{
|
||||
_logger.LogWarning("Order's status is wrong");
|
||||
@ -66,6 +71,10 @@ namespace FurnitureAssemblyBusinessLogic
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
model = Find(model);
|
||||
if (model == null) {
|
||||
return false;
|
||||
}
|
||||
if (!ChangeStatus(model, OrderStatus.Готов))
|
||||
{
|
||||
_logger.LogWarning("Order's status is wrong");
|
||||
@ -77,6 +86,11 @@ namespace FurnitureAssemblyBusinessLogic
|
||||
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
model = Find(model);
|
||||
if (model == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!ChangeStatus(model, OrderStatus.Выдан))
|
||||
{
|
||||
_logger.LogWarning("Order's status is wrong");
|
||||
@ -128,5 +142,22 @@ namespace FurnitureAssemblyBusinessLogic
|
||||
"FurnitureId:{FurnitureId}. FurnitureName:{FurnitureName}. Count:{ Count}. Sum:{ Sum}. ",
|
||||
model.Id, model.Status, model.DateCreate, model.FurnitureId, model.FurnitureName, model.Count, model.Sum);
|
||||
}
|
||||
|
||||
private OrderBindingModel Find(OrderBindingModel model)
|
||||
{
|
||||
var modelView = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
if (modelView == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
model.FurnitureId = modelView.FurnitureId;
|
||||
model.DateCreate = modelView.DateCreate;
|
||||
model.Count = modelView.Count;
|
||||
model.Sum = modelView.Sum;
|
||||
model.FurnitureId = model.FurnitureId;
|
||||
model.FurnitureName = modelView.FurnitureName;
|
||||
model.Status = modelView.Status;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user