64 lines
1.8 KiB
C#
64 lines
1.8 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using SushiBarContracts.BindingModels;
|
|
using SushiBarContracts.ViewModels;
|
|
using SushiBarDataModels.Models;
|
|
|
|
namespace SushiBarDatabaseImplement.Models;
|
|
|
|
public class Implementer : IImplementerModel
|
|
{
|
|
public int Id { get; private init; }
|
|
[Required] public string ImplementerFio { get; private set; } = string.Empty;
|
|
[Required] public string Password { get; private set; } = string.Empty;
|
|
public int WorkExperience { get; private set; }
|
|
public int Qualification { get; private set; }
|
|
|
|
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 static Implementer Create(ImplementerViewModel model)
|
|
{
|
|
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
|
|
};
|
|
} |