CourseWork_CompShop/ComputerShopProvider/ComputerShopDatabaseImplement/Models/EquipmentReceiving.cs

63 lines
1.8 KiB
C#
Raw Normal View History

2023-04-07 16:10:59 +04:00
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.ViewModels;
using ComputerShopDataModels.Enums;
using ComputerShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
2023-05-18 22:18:40 +04:00
using System.ComponentModel.DataAnnotations.Schema;
2023-04-07 16:10:59 +04:00
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputerShopDatabaseImplement.Models
{
internal class EquipmentReceiving : IEquipmentReceivingModel
{
2023-12-01 19:59:06 +04:00
public DateTime? DateImplement { get; set; }
2023-04-07 16:10:59 +04:00
public int Id { get; set; }
public EquipmentReceivingStatus Status { get; private set; } = EquipmentReceivingStatus.Неизвестен;
2023-05-18 22:18:40 +04:00
[ForeignKey("ReceivingId")]
public List<Supply> Supplies { get; set; } = new();
2023-05-20 08:34:33 +04:00
[Required]
public int ClientId { get; set; }
2023-05-18 22:18:40 +04:00
2023-12-01 19:59:06 +04:00
public virtual Client Client { get; set; }
2023-04-07 16:10:59 +04:00
public static EquipmentReceiving? Create(EquipmentReceivingBindingModel? model)
{
if (model == null)
{
return null;
}
return new EquipmentReceiving
{
Status = model.Status,
DateImplement = model.DateImplement,
Id = model.Id,
2023-05-20 08:34:33 +04:00
ClientId = model.ClientId
2023-04-07 16:10:59 +04:00
};
}
public void Update(EquipmentReceivingBindingModel? model)
{
if (model == null)
{
return;
}
Status = model.Status;
DateImplement = model.DateImplement;
}
public EquipmentReceivingViewModel GetViewModel => new()
2023-12-01 19:59:06 +04:00
{
Id = Id,
Status = Status,
DateImplement = DateImplement,
ClientId = ClientId
2023-04-07 16:10:59 +04:00
};
}
}