コード例 #1
0
        /// <summary>
        /// Creates a new calendar
        /// </summary>
        /// <param name="calendar">The calendar which should be created in the database</param>
        /// <param name="creatorId">The id of the user who created the calendar</param>
        /// <returns>The newly created calendar</returns>
        public static ECalendar CreateCalendar(ECalendar calendar, int creatorId)
        {
            var db = ApplicationContext.Current.DatabaseContext.Database;

            var args = new CalendarCreationEventArgs { Calendar = calendar };
            OnCreating(args);

            if (args.Cancel)
            {
                return calendar;
            }

            db.Save(calendar);

            //Update usersettings and add the newly created calendar to the allowed calendar
            SecurityService.AddCalendarToUser(creatorId, calendar.Id);

            var args2 = new CalendarCreatedEventArgs { Calendar = calendar };
            OnCreated(args2);

            return calendar;
        }
コード例 #2
0
 public static void OnCreating(CalendarCreationEventArgs e)
 {
     EventHandler<CalendarCreationEventArgs> handler = Creating;
     if (handler != null)
     {
         handler(null, e);
     }
 }