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 DateTime DateCreate { get; set; } = DateTime.Now;
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;
[DisplayName("Дата выполнения")]
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]
public int ClientId { get; set; }
public int? ImplementerId { get; private set; }
public string JewelName { get; private set; } = string.Empty;
@ -39,6 +40,7 @@ namespace JewelryStoreDatabaseImplement.Models
public virtual Jewel Jewel { get; set; }
public virtual Client Client { get; set; }
public Implementer? Implementer { get; set; }
public static Order? Create(OrderBindingModel? model)
{
@ -52,6 +54,7 @@ namespace JewelryStoreDatabaseImplement.Models
Id = model.Id,
JewelId = model.JewelId,
ClientId = model.ClientId,
ImplementerId = model.ImplementerId,
JewelName = model.JewelName,
Count = model.Count,
Sum = model.Sum,
@ -87,13 +90,15 @@ namespace JewelryStoreDatabaseImplement.Models
Id = Id,
JewelId = JewelId,
ClientId = ClientId,
ImplementerId = ImplementerId,
ClientFIO = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty,
JewelName = context.Jewels.FirstOrDefault(x => x.Id == JewelId)?.JewelName ?? string.Empty,
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement
DateImplement = DateImplement,
ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty
};
}
}