+ добавление нового поля в сущность «Заказ»
This commit is contained in:
parent
086247bcce
commit
ba39674377
@ -12,6 +12,7 @@ namespace ConfectioneryContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int PastryId { get; set; }
|
public int PastryId { get; set; }
|
||||||
|
public int ClientId { get; set; }
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
|
@ -9,6 +9,7 @@ namespace ConfectioneryContracts.SearchModels
|
|||||||
public class OrderSearchModel
|
public class OrderSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
public int? ClientId { get; set; }
|
||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,10 @@ namespace ConfectioneryContracts.ViewModels
|
|||||||
{
|
{
|
||||||
[DisplayName("Номер")]
|
[DisplayName("Номер")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("ФИО клиента")]
|
||||||
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
public int PastryId { get; set; }
|
public int PastryId { get; set; }
|
||||||
[DisplayName("Изделие")]
|
[DisplayName("Изделие")]
|
||||||
public string PastryName { get; set; } = string.Empty;
|
public string PastryName { get; set; } = string.Empty;
|
||||||
|
@ -10,6 +10,7 @@ namespace ConfectioneryDataModels.Models
|
|||||||
public interface IOrderModel : IId
|
public interface IOrderModel : IId
|
||||||
{
|
{
|
||||||
int PastryId { get; }
|
int PastryId { get; }
|
||||||
|
int ClientId { get; }
|
||||||
int Count { get; }
|
int Count { get; }
|
||||||
double Sum { get; }
|
double Sum { get; }
|
||||||
OrderStatus Status { get; }
|
OrderStatus Status { get; }
|
||||||
|
@ -14,6 +14,10 @@ namespace ConfectioneryDatabaseImplement.Models
|
|||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[Required]
|
||||||
|
public int ClientId { get; private set; }
|
||||||
|
|
||||||
|
public virtual Client Client { get; private set; } = new();
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int PastryId { get; private set; }
|
public int PastryId { get; private set; }
|
||||||
@ -39,6 +43,8 @@ namespace ConfectioneryDatabaseImplement.Models
|
|||||||
return new Order()
|
return new Order()
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
|
ClientId = model.ClientId,
|
||||||
|
Client = context.Clients.First(x => x.Id == model.ClientId),
|
||||||
PastryId = model.PastryId,
|
PastryId = model.PastryId,
|
||||||
Pastry = context.Pastrys.First(x => x.Id == model.PastryId),
|
Pastry = context.Pastrys.First(x => x.Id == model.PastryId),
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
@ -62,6 +68,8 @@ namespace ConfectioneryDatabaseImplement.Models
|
|||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
|
ClientId = ClientId,
|
||||||
|
ClientFIO = Client.ClientFIO,
|
||||||
PastryId = PastryId,
|
PastryId = PastryId,
|
||||||
PastryName = Pastry.PastryName,
|
PastryName = Pastry.PastryName,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
|
@ -17,7 +17,7 @@ namespace ConfectioneryDatabaseImplement.Implements
|
|||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new ConfectioneryDatabase();
|
using var context = new ConfectioneryDatabase();
|
||||||
return context.Orders.Include(x => x.Pastry).Select(x => x.GetViewModel).ToList();
|
return context.Orders.Include(x => x.Pastry).Include(x => x.Client).Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
@ -27,6 +27,10 @@ namespace ConfectioneryDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
return context.Orders.Include(x => x.Pastry).Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => x.GetViewModel).ToList();
|
return context.Orders.Include(x => x.Pastry).Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
if (model.ClientId.HasValue)
|
||||||
|
{
|
||||||
|
return context.Orders.Include(x => x.Pastry).Where(x => x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
return context.Orders.Include(x => x.Pastry).Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
return context.Orders.Include(x => x.Pastry).Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user