Merge branch 'BaseLabWork03' into BaseLabWork04

This commit is contained in:
Николай 2023-03-24 15:23:02 +04:00
commit acba6156a2
2 changed files with 9 additions and 8 deletions

View File

@ -76,12 +76,7 @@ namespace FoodOrdersView
{
var operationResult = _logicO.TakeOrderInWork(new OrderBindingModel
{
Id = id,
DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].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)
{

View File

@ -59,7 +59,10 @@ namespace FoodOrdersDatabaseImplement.Implements
using var context = new FoodOrdersDatabase();
context.Orders.Add(newOrder);
context.SaveChanges();
return newOrder.GetViewModel;
return context.Orders
.Include(x => x.Dish)
.FirstOrDefault(x => x.Id == newOrder.Id)
?.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)
@ -72,7 +75,10 @@ namespace FoodOrdersDatabaseImplement.Implements
}
order.Update(model);
context.SaveChanges();
return order.GetViewModel;
return context.Orders
.Include(x => x.Dish)
.FirstOrDefault(x => x.Id == order.Id)
?.GetViewModel;
}
public OrderViewModel? Delete(OrderBindingModel model)
{