public static String deleteEvent(int id)
        {
            //idList is stored in Session by JsonResponse.ashx for security reasons
            //whenever any event is update or deleted, the event id is checked
            //whether it is present in the idList, if it is not present in the idList
            //then it may be a malicious user trying to delete someone elses events
            //thus this checking prevents misuse
            List <int> idList = (List <int>)System.Web.HttpContext.Current.Session["idList"];

            if (idList != null && idList.Contains(id))
            {
                EventDAO.deleteEvent(id);
                return("deleted event with id:" + id);
            }

            return("unable to delete event with id: " + id);
        }
        public static string UpdateEvent(CalendarEvent cevent)
        {
            List <int> idList = (List <int>)System.Web.HttpContext.Current.Session["idList"];

            if (idList != null && idList.Contains(cevent.id))
            {
                if (CheckAlphaNumeric(cevent.title) && CheckAlphaNumeric(cevent.description))
                {
                    EventDAO.updateEvent(cevent.id, cevent.title, cevent.description, cevent.status);

                    return("updated event with id:" + cevent.id + " update title to: " + cevent.title +
                           " update description to: " + cevent.description);
                }
            }

            return("unable to update event with id:" + cevent.id + " title : " + cevent.title +
                   " description : " + cevent.description);
        }
        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);
        }
        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()
            {
                title       = improperEvent.title,
                description = improperEvent.description,
                start       = Convert.ToDateTime(improperEvent.start).ToUniversalTime(),
                end         = Convert.ToDateTime(improperEvent.end).ToUniversalTime(),
                allDay      = improperEvent.allDay
            };

            if (CheckAlphaNumeric(cevent.title) && CheckAlphaNumeric(cevent.description))
            {
                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
        }
 public static string GetCustomers()
 {
     System.Web.Script.Serialization.JavaScriptSerializer oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
     return(oSerializer.Serialize(EventDAO.getCustomers()));
 }