using SewingDressesContracts.BindingModels; using SewingDressesContracts.ViewModels; using SewingDressesDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; namespace SewingDressesDatabaseImplement.Models { [DataContract] public class Implement : IImplementModel { [DataMember] public int Id { get; private set; } [Required] [DataMember] public string ImplementFIO { get; private set; } = string.Empty; [Required] [DataMember] public int WorkExperience { get; private set; } [Required] [DataMember] public string Password { get; private set; } = string.Empty; [Required] [DataMember] public int Qualification { get; private set; } [ForeignKey("ImplementId")] public virtual List? Orders { get; set; } = new(); public static Implement? Create(ImplementBindingModel? model) { if (model == null) return null; return new Implement { Id = model.Id, ImplementFIO = model.ImplementFIO, WorkExperience = model.WorkExperience, Password = model.Password, Qualification = model.Qualification, }; } public ImplementViewModel GetViewModel => new() { Id = Id, ImplementFIO = ImplementFIO, WorkExperience = WorkExperience, Password = Password, Qualification = Qualification }; public void Update(ImplementBindingModel? model) { if (model == null) return; ImplementFIO = model.ImplementFIO; WorkExperience = model.WorkExperience; Password = model.Password; Qualification = model.Qualification; } } }