Example #1
0
        public JsonResult DeleteConfirmed(int id = 0)
        {
            AlertRecipient alertRecipient = _db.AlertRecipients.FirstOrDefault(x => x.Id == id);

            if (alertRecipient == null)
            {
                TempData["ErrorMessage"] = "Something went wrong. Please try again later.";
                return(Json(new { success = false }));
            }

            _db.AlertRecipients.Remove(alertRecipient);
            _db.SaveChanges();

            TempData["SuccessMessage"] = "Alert Recipient has been deleted successfully.";

            return(Json(new { success = true }));
        }
Example #2
0
        public ActionResult Create(AlertRecipientViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                AlertRecipient alertrecipient = new AlertRecipient()
                {
                    AreaId = viewModel.AreaId,
                    Emails = viewModel.Emails,
                };

                _db.AlertRecipients.Add(alertrecipient);
                _db.SaveChanges();

                TempData["SuccessMessage"] = "Alert Recipient has been created successfully ";
                return(RedirectToAction("Index"));
            }

            viewModel.Areas = UserFunctions.GetAreasSelectList(_db, viewModel.AreaId);

            return(View(viewModel));
        }