Compare commits

..

No commits in common. "db1db180b696295e1f5d67ae2ac60c1da1d47b34" and "cb29ffb24cf8002679c6cb1b8c910fd8de6ba858" have entirely different histories.

2 changed files with 10 additions and 13 deletions

View File

@ -43,7 +43,6 @@ namespace AutomobilePlantDatabaseImplement.Implements
return context.Orders
.Include(x => x.Client)
.Include(x => x.Implementer)
.Include(x => x.Car)
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
@ -51,7 +50,6 @@ namespace AutomobilePlantDatabaseImplement.Implements
if (model.Statuses != null)
{
return context.Orders
.Include(x => x.Car)
.Include(x => x.Client)
.Include(x => x.Implementer)
.Where(x => model.Statuses.Contains(x.Status))
@ -60,7 +58,6 @@ namespace AutomobilePlantDatabaseImplement.Implements
}
return context.Orders
.Include(x => x.Car)
.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)
@ -70,7 +67,7 @@ namespace AutomobilePlantDatabaseImplement.Implements
public List<OrderViewModel> GetFullList()
{
using var context = new AutomobilePlantDatabase();
return context.Orders.Include(x => x.Car).Include(x => x.Client).Include(x => x.Implementer).Select(x => x.GetViewModel).ToList();
return context.Orders.Include(x => x.Car).Include(x => x.Implementer).Select(x => x.GetViewModel).ToList();
}
public OrderViewModel? Insert(OrderBindingModel model)
@ -83,8 +80,8 @@ namespace AutomobilePlantDatabaseImplement.Implements
using var context = new AutomobilePlantDatabase();
context.Orders.Add(newOrder);
context.SaveChanges();
return context.Orders.Include(x => x.Car).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
}
return context.Orders.Include(x => x.Car).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)
{
@ -96,14 +93,13 @@ namespace AutomobilePlantDatabaseImplement.Implements
}
order.Update(model);
context.SaveChanges();
return context.Orders.Include(x => x.Car).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
return context.Orders.Include(x => x.Car).Include(x => x.Implementer).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
}
public OrderViewModel? Delete(OrderBindingModel model)
{
using var context = new AutomobilePlantDatabase();
var element = context.Orders
.Include(x => x.Car)
.Include(x => x.Client)
.Include(x => x.Client)
.Include(x => x.Implementer)
.FirstOrDefault(x => x.Id == model.Id);
if (element != null)

View File

@ -71,6 +71,7 @@ namespace AutomobilePlantDatabaseImplement.Models
{
get
{
var context = new AutomobilePlantDatabase();
return new()
{
@ -83,10 +84,10 @@ namespace AutomobilePlantDatabaseImplement.Models
DateImplement = DateImplement,
Id = Id,
Status = Status,
CarName = Car.CarName,
ClientFIO = Client.ClientFIO,
ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty,
};
CarName = context.Cars.FirstOrDefault(x => x.Id == CarId)?.CarName ?? string.Empty,
ClientFIO = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty,
ImplementerFIO = context.Implementers.FirstOrDefault(x => x.Id == ImplementerId)?.ImplementerFIO ?? string.Empty,
};
}
}
}