using HospitalContracts.BindingModels; using HospitalContracts.ViewModels; using HospitalDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HospitalDataBaseImplements.Models { public class Recipes : IRecipesModel { public int Id { get; private set; } [Required] public string Dose { get; private set; } = string.Empty; [Required] public DateTime Date { get; private set; } = DateTime.Now; public int MedicinesId { get; private set; } [Required] public string ModeOfApplication { get; private set; } = string.Empty; private Dictionary? _recipeProcedures = null; [NotMapped] public Dictionary RecipeProcedures { get { if (_recipeProcedures == null) { // _illnessProcedures = Procedures.ToDictionary(recPC => recPC.KurseId, recPC => //(recPC.Kurse as IProceduresModel, recPC.Count)); } return _recipeProcedures; } } [ForeignKey("ProceduresId")] ///////////////// public virtual List Procedures { get; set; } = new(); private Dictionary? _recipeSymptoms = null; [NotMapped] public Dictionary RecipeSymptoms { get { if (_recipeSymptoms == null) { // _recipeSymptoms = Symptoms.ToDictionary(recPC => recPC.SymptomsId, recPC => (recPC.Symptoms as ISymptomsModel, recPC.Count)); } return _recipeSymptoms; } } [ForeignKey("SymptomsId")] ///////////////// public virtual List Symptoms { get; set; } = new(); //[Required] //public int SymptomsId { get; private set; } //public string SymptomsName { get; private set; } = string.Empty; //public virtual Symptoms Symptoms { get; set; } = new(); public static Recipes? Create(RecipesBindingModel? model) { if (model == null) { return null; } return new Recipes() { Id = model.Id, Dose = model.Dose, Date = model.Date, ModeOfApplication = model.ModeOfApplication, //SymptomsId = model.SymptomsId, //SymptomsName = model.SymptomsName }; } public void Update(RecipesBindingModel? model) { if (model == null) { return; } Dose = model.Dose; Date = model.Date; ModeOfApplication = model.ModeOfApplication; //SymptomsName = model.SymptomsName; } public RecipesViewModel GetViewModel => new() { Id = Id, Dose = Dose, Date = Date, ModeOfApplication = ModeOfApplication, //SymptomsId = SymptomsId, //SymptomsName = SymptomsName }; } }