PIbd-23_Vrazhkin_S_A_Furnit.../FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Models/Implementer.cs

73 lines
2.2 KiB
C#
Raw Normal View History

2024-04-29 18:59:10 +04:00
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.ViewModels;
using FurnitureAssemblyDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
2024-05-14 11:56:24 +04:00
using System.Runtime.Serialization;
2024-04-29 18:59:10 +04:00
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyDatabaseImplement.Models
{
2024-05-14 11:56:24 +04:00
[DataContract]
2024-04-29 18:59:10 +04:00
public class Implementer : IImplementerModel
{
2024-05-14 11:56:24 +04:00
[DataMember]
2024-04-29 18:59:10 +04:00
public int Id { get; private set; }
[Required]
2024-05-14 11:56:24 +04:00
[DataMember]
2024-04-29 18:59:10 +04:00
public string ImplementerFIO { get; private set; } = string.Empty;
[Required]
2024-05-14 11:56:24 +04:00
[DataMember]
2024-04-29 18:59:10 +04:00
public string Password { get; private set; } = string.Empty;
[Required]
2024-05-14 11:56:24 +04:00
[DataMember]
2024-04-29 18:59:10 +04:00
public int WorkExperience { get; private set; }
[Required]
2024-05-14 11:56:24 +04:00
[DataMember]
2024-04-29 18:59:10 +04:00
public int Qualification { get; private set; }
[ForeignKey("ImplementerId")]
public virtual List<Order> Orders { get; private 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
};
}
}