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