/** * Modifies a patients contact preferences to request not to be * contacted again. * * @receives - unsubscribe request from the bottom of notification based emails */ public ActionResult Unsubscribe() { try { var otp = DatabaseEmailOtpService.GetByCode(RouteData.Values["otp"].ToString()); var notification = DatabaseNotificationService.GetById(otp.NotificationId); var patient = DatabasePatientService.GetById(notification.PatientId); if (otp.IsActive()) { if (patient.object_active) { patient.ContactMethod = Patient.PrimaryContactMethod.OptOut; DatabasePatientService.Update(patient); notification.NotificationResponse = "Unsubscribe"; DatabaseNotificationService.Update(notification); DatabaseEmailOtpService.Disable(otp.Id); return(UnsubscribeSuccess()); } else { return(UnsubscribeFailure()); } } else { return(ExpiredOtp()); } } catch (Exception) { return(BadLink()); } }
/** * Sets a notification as responded to. Since the only response requried * by an email, other than ignoring it, is YES it simply starts a refill * * @receives - refill response link from sent emails */ public ActionResult Respond() { try { var otp = DatabaseEmailOtpService.GetByCode(RouteData.Values["otp"].ToString()); var notification = DatabaseNotificationService.GetById(otp.NotificationId); var patient = DatabasePatientService.GetById(notification.PatientId); if (otp.IsActive()) { if (patient.object_active) { notification.NotificationResponse = "Refill"; DatabaseNotificationService.Update(notification); var refill = DatabaseRefillService.GetByPrescriptionId(DatabasePrescriptionService.GetByPatientId(patient.PatientId).PrescriptionId); refill.RefillIt = true; DatabaseRefillService.Update(refill); DatabaseEmailOtpService.Disable(otp.Id); return(RefillSuccess()); } else { return(RefillFailure()); } } else { return(ExpiredOtp()); } } catch (Exception) { return(BadLink()); } }