Compare commits
3 Commits
3e3dc0cf2d
...
33e0d1f750
Author | SHA1 | Date | |
---|---|---|---|
33e0d1f750 | |||
42ebe7410b | |||
07dc03d48a |
@ -43,6 +43,7 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
return context.Orders
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.Include(x => x.Document)
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -50,7 +51,8 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
if (model.Status!= null)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Document)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.Where(x => model.Status.Equals(x.Status))
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -58,7 +60,8 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
}
|
||||
return context.Orders
|
||||
.Include(x => x.Document)
|
||||
.Include(x => x.Implementer)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -67,7 +70,7 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new LawFirmDatabase();
|
||||
return context.Orders.Include(x => x.Document).Include(x => x.Implementer).Select(x => x.GetViewModel).ToList();
|
||||
return context.Orders.Include(x => x.Document).Include(x => x.Client).Include(x => x.Implementer).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
@ -80,7 +83,7 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
using var context = new LawFirmDatabase();
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Document).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
|
||||
return context.Orders.Include(x => x.Document).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
@ -93,12 +96,13 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Document).Include(x => x.Implementer).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
return context.Orders.Include(x => x.Document).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new LawFirmDatabase();
|
||||
var element = context.Orders
|
||||
.Include(x => x.Document)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
@ -31,7 +31,7 @@ namespace LawFirmDatabaseImplement.Models
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
public virtual Document Document { get; set; }
|
||||
public virtual Client Client { get; set; }
|
||||
public Implementer? Implementer { get; private set; }
|
||||
public virtual Implementer? Implementer { get; set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
@ -67,10 +67,8 @@ namespace LawFirmDatabaseImplement.Models
|
||||
public OrderViewModel GetViewModel {
|
||||
get
|
||||
{
|
||||
var context = new LawFirmDatabase();
|
||||
return new ()
|
||||
{
|
||||
|
||||
DocumentId = DocumentId,
|
||||
ClientId = ClientId,
|
||||
ImplementerId = ImplementerId,
|
||||
@ -80,9 +78,9 @@ namespace LawFirmDatabaseImplement.Models
|
||||
DateImplement = DateImplement,
|
||||
Id = Id,
|
||||
Status = Status,
|
||||
DocumentName = context.Documents.FirstOrDefault(x => x.Id == DocumentId)?.DocumentName ?? string.Empty,
|
||||
ClientFIO = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty,
|
||||
ImplementerFIO = context.Implementers.FirstOrDefault(x => x.Id == ImplementerId)?.ImplementerFIO?? string.Empty,
|
||||
DocumentName = Document.DocumentName,
|
||||
ClientFIO = Client.ClientFIO,
|
||||
ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user