public async Task <IActionResult> ReminderAdd(int asisid, Reminder_Assistant rd) { ViewBag.id = asisid; try { _context.Reminder_Assistants.Add(rd); await _context.SaveChangesAsync(); return(RedirectToAction("ReminderPage", new { id = asisid })); } catch (DbUpdateException) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(RedirectToAction("ReminderPage", new { id = asisid })); }
public async Task <IActionResult> DeleteReminder(int asisId, int remId) { Reminder_Assistant rd = _context.Reminder_Assistants.Where(s => s.Id == remId).First(); try { _context.Reminder_Assistants.Remove(rd); await _context.SaveChangesAsync(); return(RedirectToAction("ReminderPage", new { id = asisId })); } 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 = asisId })); }