コード例 #1
0
        public static Event CreateEvent(Event e)
        {
            var args = new EventCreatingEventArgs { Event = e };
            OnCreating(args);

            if (args.Cancel)
            {
                return e;
            }
            ApplicationContext.Current.DatabaseContext.Database.Save(e);

            //Create the new descriptions for the new event
            e.descriptions = DescriptionService.GetDescriptionsForEvent(e.calendarId, e.Id, EventType.Normal).ToList();

            var ls = ApplicationContext.Current.Services.LocalizationService;
            foreach (var lang in ls.GetAllLanguages())
            {
                if (e.descriptions.SingleOrDefault(x => x.CultureCode == lang.CultureInfo.ToString()) == null)
                {
                    e.descriptions.Add(new EventDescription() { CalendarId = e.calendarId, EventId = e.Id, CultureCode = lang.CultureInfo.ToString(), Id = 0, Type = (int)EventType.Normal });
                }
            }

            var args2 = new EventCreatedEventArgs { Event = e };
            OnCreated(args2);

            return e;
        }
コード例 #2
0
 private string GetDescription(EventCalendar.Core.Models.Event e, string culture)
 {
     if (e.descriptions != null && e.descriptions.Any(x => x.CultureCode == culture))
     {
         return(Umbraco.StripHtml(e.descriptions.SingleOrDefault(x => x.CultureCode == culture).Content).ToString());
     }
     else
     {
         return("");
     }
 }
コード例 #3
0
        public static Event UpdateEvent(Event e)
        {
            ApplicationContext.Current.DatabaseContext.Database.Update(e);

            //Save the event descriptions                
            foreach (var desc in e.descriptions)
            {
                DescriptionService.UpdateDescription(desc);
            }

            return e;
        }
コード例 #4
0
 public Event PostSave(Event nevent)
 {
     if (nevent.Id > 0)
     {
         //Update the event
         return EventService.UpdateEvent(nevent);
     }
     else
     {
         //Insert the event
         return EventService.CreateEvent(nevent);
     }
 }