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(); } }
public void CanDeleteObjectFromDatabase() { Reminder testReminder = new Reminder("deleteTestNumber", "test message", DateTime.SpecifyKind(DateTime.Now.Date, DateTimeKind.Utc), "daily", null, DateTime.Now.AddDays(20), "appointment"); testReminder.InsertToDb(); MongoCollection<Reminder> reminderCollection = MongoAccess.GetReminderCollection(); var query = Query.EQ("_mobileNumber", "deleteTestNumber"); testReminder.DeleteFromDb(); MongoCursor<Reminder> reminderCursor = reminderCollection.Find(query); Assert.AreEqual(0, reminderCursor.Count()); }