Compare commits
No commits in common. "adea6c79224812838dfed7a3cd690f7ac0d1e05b" and "016e11b8be238a45de6915fa3da3ff888b0337c7" have entirely different histories.
adea6c7922
...
016e11b8be
@ -21,8 +21,8 @@ namespace AutomobilePlantDatabaseImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
using var context = new AutomobilePlantDatabase();
|
using var context = new AutomobilePlantDatabase();
|
||||||
return context.Orders.Include(x => x.Car).Include(x => x.Client).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
return context.Orders.Include(x => x.Car).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
@ -34,16 +34,14 @@ namespace AutomobilePlantDatabaseImplement.Implements
|
|||||||
if (model.ClientId.HasValue)
|
if (model.ClientId.HasValue)
|
||||||
{
|
{
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Car)
|
.Include(x => x.Client)
|
||||||
.Include(x => x.Client)
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
.Where(x => x.ClientId == model.ClientId)
|
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Car)
|
||||||
.Include(x => x.Car)
|
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
|
||||||
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
|
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -51,8 +49,8 @@ namespace AutomobilePlantDatabaseImplement.Implements
|
|||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new AutomobilePlantDatabase();
|
using var context = new AutomobilePlantDatabase();
|
||||||
return context.Orders.Include(x => x.Car).Include(x => x.Client).Select(x => x.GetViewModel).ToList();
|
return context.Orders.Include(x => x.Car).Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -64,8 +62,8 @@ namespace AutomobilePlantDatabaseImplement.Implements
|
|||||||
using var context = new AutomobilePlantDatabase();
|
using var context = new AutomobilePlantDatabase();
|
||||||
context.Orders.Add(newOrder);
|
context.Orders.Add(newOrder);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return context.Orders.Include(x => x.Car).Include(x => x.Client).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)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -77,8 +75,8 @@ namespace AutomobilePlantDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
order.Update(model);
|
order.Update(model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return context.Orders.Include(x => x.Car).Include(x => x.Client).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
return context.Orders.Include(x => x.Car).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||||
}
|
}
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
public OrderViewModel? Delete(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new AutomobilePlantDatabase();
|
using var context = new AutomobilePlantDatabase();
|
||||||
|
@ -67,6 +67,7 @@ namespace AutomobilePlantDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
var context = new AutomobilePlantDatabase();
|
||||||
return new()
|
return new()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -78,8 +79,8 @@ namespace AutomobilePlantDatabaseImplement.Models
|
|||||||
DateImplement = DateImplement,
|
DateImplement = DateImplement,
|
||||||
Id = Id,
|
Id = Id,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
CarName = Car.CarName,
|
CarName = context.Cars.FirstOrDefault(x => x.Id == CarId)?.CarName ?? string.Empty,
|
||||||
ClientFIO = Client.ClientFIO
|
ClientFIO = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user