public JsonResult DeleteConfirmed(int id = 0) { ReportRecipient reportRecipient = _db.ReportRecipients.FirstOrDefault(x => x.Id == id); if (reportRecipient == null) { TempData["ErrorMessage"] = "Something went wrong. Please try again later."; return(Json(new { success = false })); } _db.ReportRecipients.Remove(reportRecipient); _db.SaveChanges(); TempData["SuccessMessage"] = "Report Recipient has been deleted successfully."; return(Json(new { success = true })); }
public ActionResult Create(ReportRecipientViewModel viewModel) { if (ModelState.IsValid) { ReportRecipient reportrecipient = new ReportRecipient() { AreaId = viewModel.AreaId, Emails = viewModel.Emails, }; _db.ReportRecipients.Add(reportrecipient); _db.SaveChanges(); TempData["SuccessMessage"] = "Report Recipient has been created successfully."; return(RedirectToAction("Index")); } viewModel.Areas = UserFunctions.GetAreasSelectList(_db, viewModel.AreaId); return(View(viewModel)); }