/// <summary> /// Adds new PatientDisease entry to Database /// </summary> /// <param name="patientDisease">PatientDisease object to be added</param> /// <returns>Added PatientDisease object</returns> public async Task <PatientDisease> AddPatientDiseaseAsync(PatientDisease patientDisease) { PatientDisease patientDiseaseInserted = _unitOfWork.PatientDiseases.Insert(patientDisease); await _unitOfWork.Save(); return(patientDiseaseInserted); }
/// <summary> /// Adds Disease object to the database /// Throws exception if object with the same name alrady exists in the database /// </summary> /// <param name="disease">New Disease object</param> /// <returns>Disease object that has been added </returns> public async Task <Disease> AddDiseaseAsync(Disease disease) { if (_unitOfWork.Diseases.GetAll().Any(d => d.Name == disease.Name)) { throw new ArgumentException("Disease already exists."); } Disease diseaseInserted = _unitOfWork.Diseases.Insert(disease); await _unitOfWork.Save(); return(diseaseInserted); }
/// <summary> /// Adds DiseaseCategory entry to the database /// Throws exception if object with the same name alrady exists in the database /// </summary> /// <param name="diseaseCategory">New DiseaseCategory object</param> /// <returns>DiseaseCategory object that has been added</returns> public async Task <DiseaseCategory> AddDiseaseCategoryAsync(DiseaseCategory diseaseCategory) { if (_unitOfWork.Diseases.GetAll().Any(dc => dc.Name == diseaseCategory.Name)) { throw new ArgumentException("Category already exists."); } DiseaseCategory result = _unitOfWork.DiseaseCategories.Insert(diseaseCategory); await _unitOfWork.Save(); return(result); }