order model changed lab 6

This commit is contained in:
VictoriaPresnyakova 2023-04-17 18:44:59 +04:00
parent 5efe897906
commit f7e65c05fa
3 changed files with 11 additions and 2 deletions

View File

@ -20,6 +20,7 @@ namespace JewelryStoreContracts.BindingModels
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime DateCreate { get; set; } = DateTime.Now;
public DateTime? DateImplement { get; set; } public DateTime? DateImplement { get; set; }
public int? ImplementerId { get; set; }
} }
} }

View File

@ -33,6 +33,9 @@ namespace JewelryStoreContracts.ViewModels
public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime DateCreate { get; set; } = DateTime.Now;
[DisplayName("Дата выполнения")] [DisplayName("Дата выполнения")]
public DateTime? DateImplement { get; set; } public DateTime? DateImplement { get; set; }
public int? ImplementerId { get; set; }
[DisplayName("ФИО исполнителя")]
public string ImplementerFIO { get; set; } = string.Empty;
} }
} }

View File

@ -20,6 +20,7 @@ namespace JewelryStoreDatabaseImplement.Models
[Required] [Required]
public int ClientId { get; set; } public int ClientId { get; set; }
public int? ImplementerId { get; private set; }
public string JewelName { get; private set; } = string.Empty; public string JewelName { get; private set; } = string.Empty;
@ -39,6 +40,7 @@ namespace JewelryStoreDatabaseImplement.Models
public virtual Jewel Jewel { get; set; } public virtual Jewel Jewel { get; set; }
public virtual Client Client { get; set; } public virtual Client Client { get; set; }
public Implementer? Implementer { get; set; }
public static Order? Create(OrderBindingModel? model) public static Order? Create(OrderBindingModel? model)
{ {
@ -52,6 +54,7 @@ namespace JewelryStoreDatabaseImplement.Models
Id = model.Id, Id = model.Id,
JewelId = model.JewelId, JewelId = model.JewelId,
ClientId = model.ClientId, ClientId = model.ClientId,
ImplementerId = model.ImplementerId,
JewelName = model.JewelName, JewelName = model.JewelName,
Count = model.Count, Count = model.Count,
Sum = model.Sum, Sum = model.Sum,
@ -87,13 +90,15 @@ namespace JewelryStoreDatabaseImplement.Models
Id = Id, Id = Id,
JewelId = JewelId, JewelId = JewelId,
ClientId = ClientId, ClientId = ClientId,
ImplementerId = ImplementerId,
ClientFIO = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty, ClientFIO = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty,
JewelName = context.Jewels.FirstOrDefault(x => x.Id == JewelId)?.JewelName ?? string.Empty, JewelName = context.Jewels.FirstOrDefault(x => x.Id == JewelId)?.JewelName ?? string.Empty,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,
Status = Status, Status = Status,
DateCreate = DateCreate, DateCreate = DateCreate,
DateImplement = DateImplement DateImplement = DateImplement,
ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty
}; };
} }
} }