public void UpdateCalendarForSchedulerEventViewModel(ContentItem item, SchedulerEventViewModel model)
        {
            //var categories = _eventCategoryService.GetEventCategoriesByIdList(model.EventCategoryIds).ToList();

            var eventPart = item.As<EventPart>();

            if (model.EventCategoryIds != null && model.EventCategoryIds.Any())
            {
                _categoryService.UpdateCategoriesForEvent(item, model.EventCategoryIds);
            }

            eventPart.As<TitlePart>().Title = model.Title.Replace(@"\,",",");
            eventPart.RecurrenceId = model.RecurrenceId;
            eventPart.RecurrenceRule = model.RecurrenceRule;
            eventPart.RecurrenceException = model.RecurrenceException;
            eventPart.TimeZone = model.Timezone;
            eventPart.Description = model.Description.Replace(@"\,", ",");
            eventPart.AddressLocation = model.Location.Replace(@"\,", ",");
            eventPart.Url = model.Url;
            eventPart.ImportedFromGoogleCalendar = model.ImportFromGoogleCalendar;
            eventPart.ImportUid = model.ImportUid;

            eventPart.AllDayEvent = model.IsAllDay;

            if (model.IsAllDay && model.ImportFromGoogleCalendar)
            {
                model.End = model.End.AddDays(-1); // catch for import 
            }

            eventPart.StartDate = model.Start;
            eventPart.EndDate = model.End;
        }
 public SchedulerEventViewModel SchedulerEventViewModelFromEvent(EventPart x)
 {
     var categories = _categoryService.GetEventCategoriesByEvent(x.ContentItem).ToList();
     var data = new SchedulerEventViewModel
     {
         Id = x.Id,
         Identifier = x.Identifier,
         Title = x.Title,
         Description = x.Description,
         IsAllDay = x.AllDayEvent,
         Start = Convert.ToDateTime(x.StartDate),
         End = Convert.ToDateTime(x.EndDate),
         Url = x.Url,
         EventCategoryIds = _categoryService.GetEventCategoryIdentifiers(categories.Select(y => y.Id)).ToArray(),
         EventCategoryNames = categories.Select(y => y.CategoryName).ToArray(),
         Timezone = x.TimeZone,
         RecurrenceId = x.RecurrenceId,
         RecurrenceRule = x.RecurrenceRule,
         RecurrenceException = x.RecurrenceException,
         Location = x.AddressLocation,
         ImportFromGoogleCalendar = x.ImportedFromGoogleCalendar,
         ImportUid = x.ImportUid
     };
     return data;
 }