PIbd21_Makarov_DV_FlowerShop/FlowerShop/FlowerShopDatabaseImplement/Models/Implementer.cs

57 lines
1.4 KiB
C#

using FlowerShopContracts.BindingModels;
using FlowerShopContracts.ViewModels;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using FlowerShopDataModels.Models;
namespace FlowerShopDatabaseImplement.Models
{
public class Implementer : IImplementerModel
{
public int Id { get; set; }
[Required]
public string ImplementerFIO { get; set; } = string.Empty;
[Required]
public string Password { get; set; } = string.Empty;
[Required]
public int WorkExperience { get; set; }
[Required]
public int Qualification { get; set; }
[ForeignKey("ImplementerId")]
public virtual List<Order> Order { get; set; } = new();
public static Implementer? Create(ImplementerBindingModel? Model)
{
if (Model == null)
return null;
return new Implementer()
{
Id = Model.Id,
ImplementerFIO = Model.ImplementerFIO,
Password = Model.Password,
WorkExperience = Model.WorkExperience,
Qualification = Model.Qualification
};
}
public void Update(ImplementerBindingModel Model)
{
if (Model == null)
{
return;
}
ImplementerFIO = Model.ImplementerFIO;
Password = Model.Password;
WorkExperience = Model.WorkExperience;
Qualification = Model.Qualification;
}
public ImplementerViewModel GetViewModel => new()
{
Id = Id,
ImplementerFIO = ImplementerFIO,
Password = Password,
WorkExperience = WorkExperience,
Qualification = Qualification
};
}
}