Петрушин Егор ПИбд-22 Лабораторная №3 Юридическая фирма #3
@ -35,9 +35,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
return context.Orders
|
||||
.FirstOrDefault(x =>
|
||||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
return context.Orders.Include(x => x.Document).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
@ -49,16 +47,15 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
return context.Orders
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
.Include(x => x.Document)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
return context.Orders
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
return context.Orders.Include(x => x.Document).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
@ -71,7 +68,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
using var context = new AbstractLawFirmDataBase();
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return newOrder.GetViewModel;
|
||||
return context.Orders.Include(x => x.Document).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
@ -84,7 +81,7 @@ namespace AbstractLawFirmDatabaseImplement.Implements
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
return context.Orders.Include(x => x.Document).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ namespace AbstractLawFirmDataBaseImplement.Models
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int DocumentId { get; private set; }
|
||||
public virtual Document? Document { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
public double Sum { get; private set; }
|
||||
public OrderStatus Status { get; private set; }
|
||||
@ -54,6 +55,7 @@ namespace AbstractLawFirmDataBaseImplement.Models
|
||||
{
|
||||
Id = Id,
|
||||
DocumentId = DocumentId,
|
||||
DocumentName = Document.DocumentName,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
|
Loading…
Reference in New Issue
Block a user