using DeviceDataModels.Models; using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations; using DeviceContracts.BindingModels; using DeviceContracts.ViewModels; using DeviceDataModels.Enums; namespace DeviceDatabaseImplement.Models { public class Staff : IStaffModel { public int Id { get; set; } [Required] public string FullName { get; set; } = string.Empty; [Required] public string Department { get; set; } = string.Empty; [Required] public string Email { get; set; } = string.Empty; [Required] public string Password { get; set; } = string.Empty; [Required] public AccessLevel AccessLevel { get; set; } public virtual ICollection Ownership { get; set; } = new List(); public static Staff? Create(StaffBindingModel model) { if (model == null) return null; return new Staff { Id = model.Id, FullName = model.FullName, Department = model.Department, Email = model.Email, Password = model.Password, AccessLevel = model.AccessLevel, }; } public void Update(StaffBindingModel model) { if (model == null) return; Id = model.Id; FullName = model.FullName; Department = model.Department; Email = model.Email; Password = model.Password; AccessLevel = model.AccessLevel; } public StaffViewModel GetViewModel => new() { Id = Id, FullName = FullName, Department = Department, Email = Email, Password = Password, }; } }