CourseWork_CompShop/ComputerShopProvider/ComputerShopDatabaseImplement/Models/EquipmentReceiving.cs
2023-05-20 08:34:33 +04:00

62 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using ComputerShopContracts.BindingModels;
using ComputerShopContracts.ViewModels;
using ComputerShopDataModels.Enums;
using ComputerShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputerShopDatabaseImplement.Models
{
internal class EquipmentReceiving : IEquipmentReceivingModel
{
public DateTime? DateImplement { get; private set; }
public int Id { get; set; }
public EquipmentReceivingStatus Status { get; private set; } = EquipmentReceivingStatus.Неизвестен;
[ForeignKey("ReceivingId")]
public List<Supply> Supplies { get; set; } = new();
[Required]
public int ClientId { get; set; }
public static EquipmentReceiving? Create(EquipmentReceivingBindingModel? model)
{
if (model == null)
{
return null;
}
return new EquipmentReceiving
{
Status = model.Status,
DateImplement = model.DateImplement,
Id = model.Id,
ClientId = model.ClientId
};
}
public void Update(EquipmentReceivingBindingModel? model)
{
if (model == null)
{
return;
}
Status = model.Status;
DateImplement = model.DateImplement;
}
public EquipmentReceivingViewModel GetViewModel => new()
{
DateImplement = DateImplement,
Id = Id,
Status = Status,
ClientId = ClientId
};
}
}