PIbd-23_Ivanov_V.N._Pizzeria/Pizzeria/PizzeriaDatabaseImplement/Models/Implementer.cs

73 lines
2.0 KiB
C#
Raw Permalink Normal View History

2024-03-28 21:32:49 +04:00
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.ViewModels;
using PizzeriaDataModels.Models;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
2024-04-03 17:52:29 +04:00
using System.Runtime.Serialization;
2024-03-28 21:32:49 +04:00
namespace PizzeriaDatabaseImplement.Models
{
2024-04-03 17:52:29 +04:00
[DataContract]
2024-03-28 21:32:49 +04:00
public class Implementer : IImplementerModel
{
2024-04-03 17:52:29 +04:00
[DataMember]
2024-03-28 21:32:49 +04:00
public int Id { get; set; }
2024-04-03 17:52:29 +04:00
[DataMember]
2024-03-28 21:32:49 +04:00
[Required]
public string ImplementerFIO { get; set; } = string.Empty;
2024-04-03 17:52:29 +04:00
[DataMember]
2024-03-28 21:32:49 +04:00
[Required]
public string Password { get; set; } = string.Empty;
2024-04-03 17:52:29 +04:00
[DataMember]
2024-03-28 21:32:49 +04:00
[Required]
public int WorkExperience { get; set; }
2024-04-03 17:52:29 +04:00
[DataMember]
2024-03-28 21:32:49 +04:00
[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
};
}
}