Exemple #1
0
        public static void CalculateNextReminderDate(Reminder reminder)
        {
            if (reminder._schedule != null)
            {
                if (reminder._schedule.ToLower().Equals("daily"))
                {
                    reminder._nextScheduledReminder = reminder._nextScheduledReminder.AddDays(1);
                }
                else if (reminder._schedule.ToLower().Equals("weekly"))
                {
                    reminder._nextScheduledReminder = reminder._nextScheduledReminder.AddDays(7);
                }
                else if (reminder._schedule.ToLower().Equals("custom"))
                {
                    reminder._nextScheduledReminder = reminder._nextScheduledReminder.AddDays(1);
                    while (reminder._schedule.IndexOf(reminder._nextScheduledReminder.DayOfWeek.ToString()) == -1)
                    {
                        reminder._nextScheduledReminder = reminder._nextScheduledReminder.AddDays(1);
                    }
                }
            }

            if (reminder._schedule == null || reminder._endReminderDate == null || reminder._nextScheduledReminder > reminder._endReminderDate)
            {
                reminder.DeleteFromDb();
            }
            else
            {
                reminder.SaveToDb();
            }
        }
Exemple #2
0
        public JsonResult Appointment(Appointment appointment)
        {
            var response = new Response { Success = true };

            try
            {
                var reminderDate = ParseDate(appointment.reminderDate);

                if (appointment.oneDayNotification)
                {
                    var reminder = new Reminder
                                       {
                                           _message = appointment.message,
                                           _mobileNumber = appointment.mobile,
                                           _nextScheduledReminder = reminderDate.AddDays(-1)
                                       };
                    reminder.SaveToDb();
                }

                if (appointment.oneWeekNotification)
                {
                    var reminder = new Reminder
                                       {
                                           _mobileNumber = appointment.mobile,
                                           _message = appointment.message,
                                           _nextScheduledReminder = reminderDate.AddDays(-7)
                                       };
                    reminder.SaveToDb();
                }
            }
            catch (Exception e)
            {
                response.Success = false;
                response.ErrorMessage = appointment.reminderDate + " " + e.Message;
            }

            return Json(response);
        }
Exemple #3
0
        public JsonResult Medication(Medication medication)
        {
            var response = new Response { Success = true };

            try
            {
                var reminderStartDate = ParseDate(medication.reminderStartDate);
                var reminderEndDate = ParseDate(medication.reminderEndDate);

                var reminder = new Reminder
                                   {
                                       _nextScheduledReminder = reminderStartDate,
                                       _endReminderDate = reminderEndDate,
                                       _message = medication.message,
                                       _schedule = medication.schedule,
                                       _mobileNumber = medication.mobileNumber
                                   };

                reminder.SaveToDb();

            }
            catch (Exception e)
            {
                response.Success = false;
                response.ErrorMessage = e.Message;
            }

            return Json(response);
        }
Exemple #4
0
        public JsonResult Prescription(Prescription prescription)
        {
            var response = new Response { Success = true };

            try
            {
                var reminderDate = ParseDate(prescription.reminderDate);

                var reminder = new Reminder
                                   {
                                       _message = prescription.message,
                                       _mobileNumber = prescription.mobileNumber,
                                       _nextScheduledReminder = reminderDate
                                   };

                reminder.SaveToDb();
            }
            catch (Exception e)
            {

                response.Success = false;
                response.ErrorMessage = e.Message;
            }

            return Json(response);
        }