Пример #1
0
        protected ReminderItem CreateReminder(string name, Profile profile, DateTime dateTime, TimeSpan?remindBefore = null, ReminderRepetitions pattern = ReminderRepetitions.Once, ReminderType type = ReminderType.Custom)
        {
            var reminder = new ReminderItem();

            reminder.Name         = name;
            reminder.Profile      = profile;
            reminder.DateTime     = dateTime;
            reminder.Repetitions  = pattern;
            reminder.Type         = type;
            reminder.RemindBefore = remindBefore;
            insertToDatabase(reminder);
            return(reminder);
        }
Пример #2
0
 public void PrepareReminder(Profile dbProfile, IRemindable dtoEntry, IHasReminder entry, IHasReminder origEntry, DateTime dateTime, ReminderType type, ReminderRepetitions repetitions)
 {
     if (dtoEntry.RemindBefore.HasValue)
     {
         if (origEntry == null || origEntry.Reminder == null)
         {
             entry.Reminder = new ReminderItem();
         }
         else
         {
             entry.Reminder = origEntry.Reminder;
         }
         //entry.Reminder.ConnectedObject = entry.ToString();
         entry.Reminder.DateTime     = dateTime;
         entry.Reminder.Profile      = dbProfile;
         entry.Reminder.Type         = type;
         entry.Reminder.RemindBefore = dtoEntry.RemindBefore != TimeSpan.Zero
                                           ? dtoEntry.RemindBefore.Value
                                           : (TimeSpan?)null;
         entry.Reminder.Repetitions = repetitions;
         entry.Reminder.Name        = getReminderName(dateTime, type, dtoEntry, entry);
         Session.SaveOrUpdate(entry.Reminder);
         dbProfile.DataInfo.ReminderHash = Guid.NewGuid();
     }
     else if (origEntry != null && origEntry.Reminder != null)
     {
         Session.Delete(origEntry.Reminder);
         entry.Reminder = null;
         dbProfile.DataInfo.ReminderHash = Guid.NewGuid();
     }
 }