public ActionResult Approve(int id, int status) { try { using (var db = new Entities()) { var update = db.Reports.FirstOrDefault(x => x.ID == id); var emailOfCl = GetEmailLogin(update.CLID); var emailOfCM = GetEmailLogin(update.CMID); var emailOfPVC = GetEmailLogin(update.PVCID); if (update != null) { update.Status = status; db.SaveChanges(); MailSender mailSender = new MailSender(); mailSender.sendMail(emailOfCl, "Check Report", "Report was Approve", "gmail"); mailSender.sendMail(emailOfCM, "Check Report", "Report was Approve", "gmail"); mailSender.sendMail(emailOfPVC, "Check Report", "Report was Approve", "gmail"); return Json(new { status = true }, JsonRequestBehavior.AllowGet); } } } catch (Exception ex) { return Json(new { status = false }, JsonRequestBehavior.AllowGet); } return Json(new { status = false }, JsonRequestBehavior.AllowGet); }
public ActionResult Create(Report report) { try { using (var db = new Entities()) { report.Created = DateTime.Now; var emailOfCm = GetEmailLogin(report.CMID); //call sent email //var pathHtml = Server.MapPath("bodyEmail.html"); //var body = System.IO.File.ReadAllText(pathHtml); //body = String.Format(body, "", DateTime.Now.ToString("hh:mm dd-MM-yyyy"), ""); //var data = db.Courses.FirstOrDefault(x => x.IDCourse == courseID); db.Reports.Add(report); db.SaveChanges(); MailSender mailSender = new MailSender(); mailSender.sendMail(emailOfCm, "Check Report", "Report was submit", "gmail"); return Json(new { status = true }, JsonRequestBehavior.AllowGet); } } catch { return Json(new { status = false }, JsonRequestBehavior.AllowGet); } }