Пример #1
0
 /// <summary>
 /// Adds a Allergy to the Repository.
 /// </summary>
 /// <param name="entity">The Allergy to add to the Repository.</param>
 public void Add(Allergy entity)
 {
     Session.Save(entity);
 }
Пример #2
0
 /// <summary>
 /// Removes a Allergy from the Repository.
 /// </summary>
 /// <param name="entity">The Allergy to remove from the Repository.</param>
 public void Remove(Allergy entity)
 {
     Session.Delete(entity);
 }
Пример #3
0
        /// <summary>
        /// Create new allergy
        /// </summary>
        /// <returns></returns>
        public JsonResult CreateNewAllergy()
        {
            try
            {
                AllergyRepository allergy = new AllergyRepository();
                Allergy newAllergy = new Allergy();

                newAllergy.Name = Request.Form["AllergyName"];
                newAllergy.IsActive = true;

                allergy.Add(newAllergy);

                return Json(new
                {
                    error = false,
                    status = "Added new allergy successfully!",
                    newAllergy.Id,
                    newAllergy.Name
                });
            }
            catch (Exception e)
            {
                return Json(new
                {
                    error = "true",
                    status = "Unable to add allergy!",
                    errorMessage = e.Message
                });
            }
        }