/// <summary> /// Adds a Medication to the Repository. /// </summary> /// <param name="entity">The Medication to add to the Repository.</param> public void Add(Medication entity) { Session.Save(entity); }
/// <summary> /// Removes a Medication from the Repository. /// </summary> /// <param name="entity">The Medication to remove from the Repository.</param> public void Remove(Medication entity) { Session.Delete(entity); }
/// <summary> /// Create new medication /// </summary> /// <returns></returns> public JsonResult CreateNewMedication() { try { Medication pMed = new Medication(); pMed.Name = Request.Form["MedicationName"]; pMed.Description = Request.Form["MedicationDescription"]; pMed.IsActive = true; MedicationRepository medicationRepo = new MedicationRepository(); medicationRepo.Add(pMed); return Json(new { error = "false", Name = pMed.Name, Id = pMed.Id }); } catch (Exception e) { return Json(new { error = "true", status = "Unable to add new medication successfully", errorMessage = e.Message }); } }