исравление изменения статусов заказа
This commit is contained in:
parent
46439ae569
commit
c69a473c11
@ -71,9 +71,9 @@ namespace SushiBar.Forms
|
|||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id});
|
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
|
@ -14,19 +14,20 @@ namespace SushiBarDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
using var context = new SushiBarDatabase();
|
using var context = new SushiBarDatabase();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Sushi)
|
.Include(o => o.Sushi)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(o => o.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
var result = new List<OrderViewModel>();
|
using var context = new SushiBarDatabase();
|
||||||
var element = GetElement(model);
|
return context.Orders
|
||||||
if (element != null)
|
.Include(o => o.Sushi)
|
||||||
{
|
.Where(o =>
|
||||||
result.Add(element);
|
(model.Id.HasValue && o.Id == model.Id) ||
|
||||||
}
|
(model.DateFrom.HasValue && model.DateTo.HasValue && model.DateFrom < o.DateCreate && o.DateCreate < model.DateTo))
|
||||||
return new();
|
.Select(o => o.GetViewModel)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
@ -36,8 +37,8 @@ namespace SushiBarDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
using var context = new SushiBarDatabase();
|
using var context = new SushiBarDatabase();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include (x => x.Sushi)
|
.Include (o => o.Sushi)
|
||||||
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
.FirstOrDefault(o => o.Id == model.Id)?.GetViewModel;
|
||||||
}
|
}
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -57,7 +58,7 @@ namespace SushiBarDatabaseImplement.Implements
|
|||||||
using var transaction = context.Database.BeginTransaction();
|
using var transaction = context.Database.BeginTransaction();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var order = context.Orders.FirstOrDefault(rec =>
|
var order = context.Orders.Include(o => o.Sushi).FirstOrDefault(rec =>
|
||||||
rec.Id == model.Id);
|
rec.Id == model.Id);
|
||||||
if (order == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
@ -78,7 +79,7 @@ namespace SushiBarDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
using var context = new SushiBarDatabase();
|
using var context = new SushiBarDatabase();
|
||||||
var element = context.Orders
|
var element = context.Orders
|
||||||
.FirstOrDefault(x => x.Id == model.Id);
|
.FirstOrDefault(o => o.Id == model.Id);
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
context.Orders.Remove(element);
|
context.Orders.Remove(element);
|
||||||
|
Loading…
Reference in New Issue
Block a user