public static object InsertMethodHandler(SchedulerAppointment newAppointment)
        {
            List <SchedulerAppointment> list = GetAppointments();
            long maxId = list.Count == 0 ? 0 : list.Max(i => i.Id);

            newAppointment.Id = maxId + 1;
            list.Add(newAppointment);

            UpdateAppointments(list);

            return(newAppointment.Id); // DXCOMMENT: Return this value to the ASPxScheduler and set the ASPxScheduler.ASPxAppointmentStorage.AutoRetrieveId ( https://documentation.devexpress.com/AspNet/DevExpress.Web.ASPxScheduler.ASPxAppointmentStorage.AutoRetrieveId.property ) property to true.
        }
        public static void DeleteMethodHandler(SchedulerAppointment deletedAppointment)
        {
            List <SchedulerAppointment> list = GetAppointments();
            SchedulerAppointment        item = list.FirstOrDefault(i => i.Id.Equals(deletedAppointment.Id));

            if (item != null)
            {
                list.Remove(item);
            }

            UpdateAppointments(list);
        }
        public static void UpdateMethodHandler(SchedulerAppointment updatedAppointment)
        {
            List <SchedulerAppointment> list = GetAppointments();
            SchedulerAppointment        item = list.FirstOrDefault(i => i.Id.Equals(updatedAppointment.Id));

            item.AllDay         = updatedAppointment.AllDay;
            item.Description    = updatedAppointment.Description;
            item.StartDate      = updatedAppointment.StartDate;
            item.EndDate        = updatedAppointment.EndDate;
            item.EventType      = updatedAppointment.EventType;
            item.LabelId        = updatedAppointment.LabelId;
            item.Location       = updatedAppointment.Location;
            item.RecurrenceInfo = updatedAppointment.RecurrenceInfo;
            item.Status         = updatedAppointment.Status;
            item.Subject        = updatedAppointment.Subject;
            item.ResourceId     = updatedAppointment.ResourceId;

            UpdateAppointments(list);
        }
        private static List <SchedulerAppointment> GenerateAppointments()
        {
            List <SchedulerAppointment> list = new List <SchedulerAppointment>();

            int      uniqueID  = 0;
            DateTime startDate = DateTime.Now.Date;
            Random   random    = new Random();

            // Birthdays - from Contacts
            for (int i = 0; i < DataProvider.GetContacts().Count; i++)
            {
                Contact contact = DataProvider.GetContacts()[i];

                SchedulerAppointment appointment = new SchedulerAppointment();
                appointment.Id         = uniqueID;
                appointment.Subject    = contact.FirstName + " " + contact.LastName;
                appointment.AllDay     = true;
                appointment.StartDate  = contact.Birthday.Date;
                appointment.EndDate    = appointment.StartDate.AddDays(1);
                appointment.EventType  = (int)AppointmentType.Pattern;                                                   // Represents the appointment which serves as the pattern for the other recurring appointments
                appointment.LabelId    = SchedulerLabelsHelper.GetItems().FirstOrDefault(c => c.Name == "Birthdays").Id; // Birthday label
                appointment.ResourceId = random.Next(1, ResourceDataSourceHelper.GetItems().Count + 1);

                RecurrenceInfo recInfo = new RecurrenceInfo();
                recInfo.Start              = appointment.StartDate;
                recInfo.Range              = RecurrenceRange.NoEndDate;
                recInfo.Type               = RecurrenceType.Yearly;
                recInfo.Periodicity        = 1;
                recInfo.Month              = contact.Birthday.Month;
                recInfo.DayNumber          = contact.Birthday.Day;
                appointment.RecurrenceInfo = recInfo.ToXml();

                list.Add(appointment);
                uniqueID++;
            }

            // Sample Appointments
            for (int i = -100; i < 100; i++)
            {
                if (i != 0 && i % random.Next(7, 10) == 0)
                {
                    continue;
                }

                SchedulerAppointment appointment = new SchedulerAppointment();
                appointment.Id      = uniqueID;
                appointment.Subject = "Appointment " + uniqueID.ToString();
                int h = random.Next(7, 18);
                appointment.StartDate  = startDate.AddDays(i).AddHours(h);
                appointment.EndDate    = appointment.StartDate.AddHours(random.Next(2, 4));
                appointment.EventType  = (int)AppointmentType.Normal; // Represents a standard (non-recurring) appointment
                appointment.LabelId    = random.Next(1, 4);
                appointment.ResourceId = random.Next(1, ResourceDataSourceHelper.GetItems().Count + 1);
                appointment.Status     = random.Next(1, 5);

                list.Add(appointment);
                uniqueID++;
            }

            return(list);
        }