コード例 #1
0
        public static string UpdateEventTime(ImproperCalendarEvent improperEvent)
        {
            List<int> idList = (List<int>)System.Web.HttpContext.Current.Session["idList"];
            if (idList != null && idList.Contains(improperEvent.id))
            {
                // FullCalendar 1.x
                //EventDAO.updateEventTime(improperEvent.id,
                //    DateTime.ParseExact(improperEvent.start, "dd-MM-yyyy hh:mm:ss tt", CultureInfo.InvariantCulture),
                //    DateTime.ParseExact(improperEvent.end, "dd-MM-yyyy hh:mm:ss tt", CultureInfo.InvariantCulture));

                // FullCalendar 2.x
                EventDAO.updateEventTime(improperEvent.id,
                                         Convert.ToDateTime(improperEvent.start).ToUniversalTime(),
                                         Convert.ToDateTime(improperEvent.end).ToUniversalTime(),
                                         improperEvent.allDay);  //allDay parameter added for FullCalendar 2.x

                return "updated event with id:" + improperEvent.id + " update start to: " + improperEvent.start +
                    " update end to: " + improperEvent.end;
            }

            return "unable to update event with id: " + improperEvent.id;
        }
コード例 #2
0
        public static int addEvent(ImproperCalendarEvent improperEvent)
        {
            // FullCalendar 1.x
            //CalendarEvent cevent = new CalendarEvent()
            //{
            //    title = improperEvent.title,
            //    description = improperEvent.description,
            //    start = DateTime.ParseExact(improperEvent.start, "dd-MM-yyyy hh:mm:ss tt", CultureInfo.InvariantCulture),
            //    end = DateTime.ParseExact(improperEvent.end, "dd-MM-yyyy hh:mm:ss tt", CultureInfo.InvariantCulture)
            //};

            // FullCalendar 2.x
            CalendarEvent cevent = new CalendarEvent()
            {
                Nome = improperEvent.title,
                Oggetto = improperEvent.description,
                Data = Convert.ToDateTime(improperEvent.start).ToUniversalTime(),
                DataEnd = Convert.ToDateTime(improperEvent.end).ToUniversalTime(),
                allDay = improperEvent.allDay
            };

            if (CheckAlphaNumeric(cevent.Nome) && CheckAlphaNumeric(cevent.Oggetto))
            {
                int key = EventDAO.addEvent(cevent);

                List<int> idList = (List<int>)System.Web.HttpContext.Current.Session["idList"];

                if (idList != null)
                {
                    idList.Add(key);
                }

                return key; //return the primary key of the added cevent object
            }

            return -1; //return a negative number just to signify nothing has been added
        }