using HospitalContracts.BindingModels; using HospitalContracts.ViewModels; using HospitalDataModels.Models; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace HospitalDatabaseImplement.Models { public class Apothecary : IApothecaryModel { public int Id { get; private set; } [Required] [MaxLength(50)] public string Login { get; private set; } = string.Empty; [Required] [MaxLength(55)] public string Password { get; private set; } = string.Empty; [ForeignKey("ApothecaryId")] public virtual List Medicines { get; set; } = new(); [ForeignKey("ApothecaryId")] public virtual List Recipes { get; set; } = new(); [ForeignKey("ApothecaryId")] public virtual List Prescriptions { get; set; } = new(); public static Apothecary? Create(ApothecaryBindingModel model) { if (model == null) { return null; } return new Apothecary() { Id = model.Id, Login = model.Login, Password = model.Password }; } public void Update(ApothecaryBindingModel model) { if (model == null) { return; } Login = model.Login; Password = model.Password; } public ApothecaryViewModel GetViewModel => new() { Id = Id, Login = Login, Password = Password }; } }