public JsonResult AddNewFormula([Bind(Exclude = "ID")] EnteralFormula ef) { DTO dto = new DTO(); if (ModelState.IsValid) { if (CalorieCalc.IsFormulaNameDuplicate(ef.Name) == 1) { dto.ReturnValue = 0; dto.Message = ef.Name + " is already in the list!"; } else { dto = CalorieCalc.AddFormula(ef); var siteId = DbUtils.GetSiteidIdForUser(User.Identity.Name); var staff = NotificationUtils.GetStaffForEvent(4, siteId); string siteName = DbUtils.GetSiteNameForUser(User.Identity.Name); var u = new UrlHelper(this.Request.RequestContext); string url = "http://" + this.Request.Url.Host + u.RouteUrl("Default", new { Controller = "Account", Action = "Logon" }); Utility.SendFormulaAddeddMail(staff.ToArray(), null, ef, User.Identity.Name, siteName, Server, url); } dto.Bag = ef; return(Json(dto)); } else { return(null); } }
public ActionResult FormulaDetails([Bind(Include = "ID, Name, Kcal_ml, ProteinKcal," + "ChoKcal, LipidKcal")] EnteralFormula enteralFormula) { if (ModelState.IsValid) { var dto = CalorieCalc.UpdateFormula(enteralFormula); if (dto.ReturnValue == 1) { TempData.Add("enteralFormula", enteralFormula); return(RedirectToAction("FormulaConfirmation")); } } return(View(enteralFormula)); }
public static void SendFormulaAddeddMail(string[] toAddress, string[] ccAddress, EnteralFormula formula, string name, string siteName, HttpServerUtilityBase server, string url) { string subject = "Halfpint - New Formula Added"; StringBuilder sbBody = new StringBuilder("<p>" + name + " from " + siteName + " has added a new formula:</p>"); sbBody.Append("<table><tr><th>Name</th><th>" + formula.Name +"</th></tr>"); sbBody.Append("<tr><td>CHO %</td><td>" + formula.ChoKcal + "</td></tr>"); sbBody.Append("<tr><td>Lipid %</td><td>" + formula.LipidKcal + "</td></tr>"); sbBody.Append("<tr><td>Protein %</td><td>" + formula.ProteinKcal + "</td></tr>"); sbBody.Append("<tr><td>kCal/mL</td><td>" + formula.Kcal_ml + "</td></tr>"); sbBody.Append("</table>"); string siteUrl = "Website: <a href='" + url + "'>HalfpintStudy.org</a>"; SendHtmlEmail(subject, toAddress, ccAddress, sbBody.ToString(), server, siteUrl); }