2024-05-20 05:17:39 +04:00

60 lines
1.8 KiB
C#

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> Ownership { get; set; }
= new List<Ownership>();
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,
};
}
}