Последние фиксы
This commit is contained in:
parent
f550a6900b
commit
9af0c201fb
@ -88,7 +88,6 @@ namespace SushiBarView
|
|||||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||||
{
|
{
|
||||||
SushiId = Convert.ToInt32(comboBoxSushi.SelectedValue),
|
SushiId = Convert.ToInt32(comboBoxSushi.SelectedValue),
|
||||||
SushiName = comboBoxSushi.Text,
|
|
||||||
Count = Convert.ToInt32(textBoxCount.Text),
|
Count = Convert.ToInt32(textBoxCount.Text),
|
||||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||||
});
|
});
|
||||||
|
@ -75,12 +75,6 @@ namespace SushiBarView
|
|||||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
SushiId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SushiId"].Value),
|
|
||||||
SushiName = dataGridView.SelectedRows[0].Cells["SushiName"].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()),
|
|
||||||
});
|
});
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
@ -106,12 +100,6 @@ namespace SushiBarView
|
|||||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
SushiId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SushiId"].Value),
|
|
||||||
SushiName = dataGridView.SelectedRows[0].Cells["SushiName"].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()),
|
|
||||||
});
|
});
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
@ -137,12 +125,6 @@ namespace SushiBarView
|
|||||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
SushiId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SushiId"].Value),
|
|
||||||
SushiName = dataGridView.SelectedRows[0].Cells["SushiName"].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()),
|
|
||||||
});
|
});
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
|
@ -75,14 +75,27 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||||
if (model.Status + 1 != newStatus)
|
if (viewModel == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (viewModel.Status + 1 != newStatus)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
|
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
model.Status = newStatus;
|
model.Status = newStatus;
|
||||||
|
model.SushiId = viewModel.SushiId;
|
||||||
|
model.Count = viewModel.Count;
|
||||||
|
model.Sum = viewModel.Sum;
|
||||||
|
model.DateCreate = viewModel.DateCreate;
|
||||||
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model.DateImplement = viewModel.DateImplement;
|
||||||
|
}
|
||||||
|
CheckModel(model);
|
||||||
if (_orderStorage.Update(model) == null)
|
if (_orderStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
model.Status--;
|
model.Status--;
|
||||||
|
@ -6,7 +6,6 @@ namespace SushiBarContracts.BindingModels
|
|||||||
public class OrderBindingModel : IOrderModel
|
public class OrderBindingModel : IOrderModel
|
||||||
{
|
{
|
||||||
public int SushiId { get; set; }
|
public int SushiId { get; set; }
|
||||||
public string SushiName { get; set; } = string.Empty;
|
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
|
@ -18,7 +18,7 @@ namespace SushiBarListImplement.Implements
|
|||||||
var result = new List<OrderViewModel>();
|
var result = new List<OrderViewModel>();
|
||||||
foreach (var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
{
|
{
|
||||||
result.Add(order.GetViewModel);
|
result.Add(GetViewModel(order));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ namespace SushiBarListImplement.Implements
|
|||||||
{
|
{
|
||||||
if (order.Id == model.Id)
|
if (order.Id == model.Id)
|
||||||
{
|
{
|
||||||
result.Add(order.GetViewModel);
|
result.Add(GetViewModel(order));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -48,11 +48,24 @@ namespace SushiBarListImplement.Implements
|
|||||||
{
|
{
|
||||||
if (model.Id.HasValue && order.Id == model.Id)
|
if (model.Id.HasValue && order.Id == model.Id)
|
||||||
{
|
{
|
||||||
return order.GetViewModel;
|
return GetViewModel(order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
private OrderViewModel GetViewModel(Order order)
|
||||||
|
{
|
||||||
|
var viewModel = order.GetViewModel;
|
||||||
|
foreach (var iceCream in _source.ListSushi)
|
||||||
|
{
|
||||||
|
if (iceCream.Id == order.SushiId)
|
||||||
|
{
|
||||||
|
viewModel.SushiName = iceCream.SushiName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return viewModel;
|
||||||
|
}
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
model.Id = 1;
|
model.Id = 1;
|
||||||
@ -69,7 +82,7 @@ namespace SushiBarListImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_source.Orders.Add(newOrder);
|
_source.Orders.Add(newOrder);
|
||||||
return newOrder.GetViewModel;
|
return GetViewModel(newOrder);
|
||||||
}
|
}
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -78,7 +91,7 @@ namespace SushiBarListImplement.Implements
|
|||||||
if (order.Id == model.Id)
|
if (order.Id == model.Id)
|
||||||
{
|
{
|
||||||
order.Update(model);
|
order.Update(model);
|
||||||
return order.GetViewModel;
|
return GetViewModel(order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -91,7 +104,7 @@ namespace SushiBarListImplement.Implements
|
|||||||
{
|
{
|
||||||
var element = _source.Orders[i];
|
var element = _source.Orders[i];
|
||||||
_source.Orders.RemoveAt(i);
|
_source.Orders.RemoveAt(i);
|
||||||
return element.GetViewModel;
|
return GetViewModel(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -9,7 +9,6 @@ namespace SushiBarListImplement.Models
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public int SushiId { get; private set; }
|
public int SushiId { get; private set; }
|
||||||
public string SushiName { get; private set; } = string.Empty;
|
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||||
@ -24,7 +23,6 @@ namespace SushiBarListImplement.Models
|
|||||||
return new Order
|
return new Order
|
||||||
{
|
{
|
||||||
SushiId = model.SushiId,
|
SushiId = model.SushiId,
|
||||||
SushiName = model.SushiName,
|
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
@ -40,7 +38,6 @@ namespace SushiBarListImplement.Models
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SushiId = model.SushiId;
|
SushiId = model.SushiId;
|
||||||
SushiName = model.SushiName;
|
|
||||||
Count = model.Count;
|
Count = model.Count;
|
||||||
Sum = model.Sum;
|
Sum = model.Sum;
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
@ -51,7 +48,6 @@ namespace SushiBarListImplement.Models
|
|||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
SushiId = SushiId,
|
SushiId = SushiId,
|
||||||
SushiName = SushiName,
|
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
|
Loading…
Reference in New Issue
Block a user