using HotelContracts.BindingModels; using HotelContracts.ViewModels; using HotelDataModels.Models; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HotelDatabaseImplement.Models { public class Worker : IWorkerModel { public int PostId { get; set; } public string FIO { get; set; } = string.Empty; public DateTime DateOfBirth { get; set; } public int WorkExperience { get; set; } public int Salary { get; set; } public string Phone { get; set; } = string.Empty; public int Id { get; set; } public static Worker? Create(WorkerBindingModel model) { if (model == null) return null; return new Worker() { Id = model.Id, PostId = model.PostId, FIO = model.FIO, DateOfBirth = model.DateOfBirth, WorkExperience = model.WorkExperience, Salary = model.Salary, Phone = model.Phone }; } public void Update(WorkerBindingModel model) { if (model == null) return; Id = model.Id; PostId = model.PostId; FIO = model.FIO; DateOfBirth = model.DateOfBirth; WorkExperience = model.WorkExperience; Salary = model.Salary; Phone = model.Phone; } public WorkerViewModel GetViewModel => new() { Id = Id, PostId = PostId, FIO = FIO, DateOfBirth = DateOfBirth, WorkExperience = WorkExperience, Salary = Salary, Phone = Phone }; } }