public async Task <IActionResult> ReminderAdd(String insid, Reminder_Insurance rd) { ViewBag.id = insid; try { _context.Reminder_Insurances.Add(rd); await _context.SaveChangesAsync(); return(RedirectToAction("ReminderPage", new { id = insid })); } catch (DbUpdateException) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(RedirectToAction("ReminderPage", new { id = insid })); }
public async Task <IActionResult> DeleteReminder(String insId, int remId) { Reminder_Insurance rd = _context.Reminder_Insurances.Where(s => s.Id == remId).First(); try { _context.Reminder_Insurances.Remove(rd); await _context.SaveChangesAsync(); return(RedirectToAction("ReminderPage", new { id = insId })); } catch (DbUpdateException) { //Log the error (uncomment ex variable name and write a log. ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } await _context.SaveChangesAsync(); return(RedirectToAction("ReminderPage", new { id = insId })); }