Exemplo n.º 1
0
 /// <summary>
 /// Inserts the reminder into the database.
 /// </summary>
 /// <param name="rem">The reminder you want added into the database</param>
 public static long PushReminderToDatabase(Reminder rem)
 {
     if (rem != null)
     {
         return(DLReminders.PushReminderToDatabase(rem));
     }
     else
     {
         return(-1);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Inserts a new reminder into the database
        /// </summary>
        /// <param name="name">The name of the reminder</param>
        /// <param name="date">The date the reminder should pop up</param>
        /// <param name="repeatingType"></param>
        /// <param name="dayOfWeek">The day of the week this reminder should pop up at each week. Use null if the reminder isn't weekly</param>
        /// <param name="everyXDays">The amount of x. example: every 5 days</param>
        /// <param name="commaSeperatedDays">a string with days seperated by a comma. example: monday,friday,sunday</param>
        /// <param name="note">The optional note of this reminder</param>
        /// <param name="enabled">Wether this reminder is enabled or not. 1 = enabled   0 = not enabled</param>
        /// <param name="soundPath">The path to the sound effect that should play when this reminder pops up</param>
        /// <returns>Returns the ID of the newly inserted reminder</returns>
        public static long InsertReminder(string name, string date, string repeatingType, long?everyXDays, string commaSeperatedDays, string note, bool enabled, string soundPath, int updateTime = 0)
        {
            Reminder rem = new Reminder();

            rem.Name = name;

            DateTime test;

            //If split by comma [1] (second value) is not a datetime, it means the date is a single date WITH a comma in it. we gotta fix that
            if (date.Split(',').Length > 1 && !DateTime.TryParse(date.Split(',')[1], out test))
            {
                //The date contains a ',' , no good! Try and convert it to en-us
                date = DateTime.Parse(date.ToString(), CultureInfo.CurrentCulture).ToString();

                if (date.Contains(","))//Still contains a comma? Let's just convert it to en-us then..
                {
                    date = DateTime.Parse(date.ToString(), new CultureInfo("en-US")).ToString();
                }
            }

            rem.Date = date;


            rem.RepeatType = repeatingType.ToString();

            //below are nullable parameters. a reminder can have a dayofmonth, if it does, it won't have a everyXDays.
            if (everyXDays.HasValue)
            {
                rem.EveryXCustom = everyXDays;
            }

            //will containall selected days. example: "monday,thursday,saturday"
            if (commaSeperatedDays != null && commaSeperatedDays != "")
            {
                rem.RepeatDays = commaSeperatedDays;
            }

            rem.Note          = note;
            rem.SoundFilePath = soundPath;
            if (enabled)
            {
                rem.Enabled = 1;
            }
            else
            {
                rem.Enabled = 0;
            }

            rem.UpdateTime = updateTime;

            return(DLReminders.PushReminderToDatabase(rem));
        }