using PersonnelDepartmentContracts.BindingModels; using PersonnelDepartmentContracts.ViewModels; using PersonnelDepartmentDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PersonnelDepartmentDatabaseImplement.Models { public class Department : IDepartmentModel { [Required] public string Name { get; set; } = string.Empty; [Required] public int Telephone { get; set; } public int Id { get; set; } public static Department? Create(DepartmentBindingModel model) { if (model == null) { return null; } return new Department { Id = model.Id, Name = model.Name, Telephone = model.Telephone }; } public void Update(DepartmentBindingModel model) { if (model == null) { return; } Name = model.Name; Telephone = model.Telephone; } public DepartmentViewModel GetViewModel => new() { Id = Id, Name = Name, Telephone = Telephone }; } }