2024-05-12 19:24:51 +04:00
|
|
|
|
using FishFactoryContracts.BindingModels;
|
|
|
|
|
using FishFactoryContracts.ViewModels;
|
|
|
|
|
using FishFactoryDataModel.Models;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2024-06-18 15:56:18 +04:00
|
|
|
|
using System.Runtime.Serialization;
|
2024-05-12 19:24:51 +04:00
|
|
|
|
|
|
|
|
|
namespace FishFactoryDatabaseImplement.Models
|
|
|
|
|
{
|
2024-06-18 15:56:18 +04:00
|
|
|
|
[DataContract]
|
|
|
|
|
public class Implementer : IImplementerModel
|
2024-05-12 19:24:51 +04:00
|
|
|
|
{
|
2024-06-18 15:56:18 +04:00
|
|
|
|
[DataMember]
|
|
|
|
|
public int Id { get; private set; }
|
2024-05-12 19:24:51 +04:00
|
|
|
|
|
2024-06-18 15:56:18 +04:00
|
|
|
|
[DataMember]
|
|
|
|
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
2024-05-12 19:24:51 +04:00
|
|
|
|
|
2024-06-18 15:56:18 +04:00
|
|
|
|
[DataMember]
|
|
|
|
|
public string Password { get; private set; } = string.Empty;
|
2024-05-12 19:24:51 +04:00
|
|
|
|
|
2024-06-18 15:56:18 +04:00
|
|
|
|
[DataMember]
|
|
|
|
|
public int WorkExperience { get; private set; } = 0;
|
2024-05-12 19:24:51 +04:00
|
|
|
|
|
2024-06-18 15:56:18 +04:00
|
|
|
|
[DataMember]
|
|
|
|
|
public int Qualification { get; private set; } = 0;
|
2024-05-12 19:24:51 +04:00
|
|
|
|
[ForeignKey("ImplementerId")]
|
|
|
|
|
public virtual List<Order> Order { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
public static Implementer? Create(ImplementerBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Password = model.Password,
|
|
|
|
|
Qualification = model.Qualification,
|
|
|
|
|
ImplementerFIO = model.ImplementerFIO,
|
|
|
|
|
WorkExperience = model.WorkExperience,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(ImplementerBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Password = model.Password;
|
|
|
|
|
Qualification = model.Qualification;
|
|
|
|
|
ImplementerFIO = model.ImplementerFIO;
|
|
|
|
|
WorkExperience = model.WorkExperience;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ImplementerViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
ImplementerFIO = ImplementerFIO,
|
|
|
|
|
Password = Password,
|
|
|
|
|
Qualification = Qualification,
|
2024-05-13 22:15:56 +04:00
|
|
|
|
WorkExperience = WorkExperience,
|
2024-05-12 19:24:51 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|