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