public new static object GetSample()
 {
     return(new
     {
         canEditTimeZone = false,
         timeZone = TimeZoneWrapper.GetSample(),
         defaultAlert = EventAlertWrapper.GetSample(),
         events = new List <object>()
         {
             EventWrapper.GetSample()
         },
         owner = UserParams.GetSample(),
         objectId = "1",
         title = "Calendar Name",
         description = "Calendar Description",
         backgroundColor = "#000000",
         textColor = "#ffffff",
         isEditable = true,
         permissions = CalendarPermissions.GetSample(),
         isShared = true,
         canAlertModify = true,
         isHidden = false,
         isiCalStream = false,
         isSubscription = false,
         group = "Personal Calendars",
         isNew = true,
         isSubscribed = false,
     });
 }
예제 #2
0
        public static List<EventWrapper> GetEventWrappers(this BaseCalendar calendar, Guid userId, ApiDateTime startDate, ApiDateTime endDate)
        {   
            var result = new List<EventWrapper>();
            if (calendar != null)
            {
                var events = calendar.LoadEvents(userId, startDate.UtcTime, endDate.UtcTime);
                foreach (var e in events)
                {
                    var wrapper = new EventWrapper(e, userId, calendar.TimeZone);
                    var listWrapper = wrapper.GetList(startDate.UtcTime, endDate.UtcTime);
                    result.AddRange(listWrapper);
                }
            }

            return result;
        }
예제 #3
0
        public List<EventWrapper> RemoveEvent(int eventId, ApiDateTime date, EventRemoveType type)
        {
            var events = new List<EventWrapper>();
            var evt = _dataProvider.GetEventById(eventId);
            var cal = _dataProvider.GetCalendarById(Convert.ToInt32(evt.CalendarId));

            if (evt.OwnerId.Equals(SecurityContext.CurrentAccount.ID) || CheckPermissions(evt, CalendarAccessRights.FullAccessAction, true) || CheckPermissions(cal, CalendarAccessRights.FullAccessAction, true))
            {
                if (type == EventRemoveType.AllSeries || evt.RecurrenceRule.Freq == Frequency.Never)
                {
                    _dataProvider.RemoveEvent(eventId);
                    return events;
                }

                else if (type == EventRemoveType.Single)
                    evt.RecurrenceRule.ExDates.Add(new RecurrenceRule.ExDate() { Date = date.UtcTime.Date, isDateTime = false });

                else if (type == EventRemoveType.AllFollowing)
                {
                    evt.RecurrenceRule.Until = date.UtcTime.Date;
                    if (!evt.AllDayLong)
                        evt.RecurrenceRule.Until = evt.RecurrenceRule.Until.Add(evt.UtcStartDate.TimeOfDay);
                }

                evt = _dataProvider.UpdateEvent(int.Parse(evt.Id), int.Parse(evt.CalendarId), evt.OwnerId, evt.Name, evt.Description,
                                              evt.UtcStartDate, evt.UtcEndDate, evt.RecurrenceRule, evt.AlertType, evt.AllDayLong,
                                              evt.SharingOptions.PublicItems);

                //define timeZone
                TimeZoneInfo timeZone;
                if (!CheckPermissions(cal, CalendarAccessRights.FullAccessAction, true))
                {
                    timeZone = _dataProvider.GetTimeZoneForSharedEventsCalendar(SecurityContext.CurrentAccount.ID);
                    evt.CalendarId = SharedEventsCalendar.CalendarId;
                }
                else
                    timeZone = _dataProvider.GetTimeZoneForCalendar(SecurityContext.CurrentAccount.ID, int.Parse(evt.CalendarId));

                events = new EventWrapper(evt, SecurityContext.CurrentAccount.ID, timeZone).GetList(evt.UtcStartDate, date.UtcTime.AddMonths(_monthCount));
            }
            else
                _dataProvider.UnsubscribeFromEvent(eventId, SecurityContext.CurrentAccount.ID);

            return events;
        }