[WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static List<ScheduleAppointment> CrudResult(List<ScheduleAppointment> added, List<ScheduleAppointment> changed, List<ScheduleAppointment> deleted) { ScheduleDataDataContext db = new ScheduleDataDataContext(); int intMax = db.ScheduleAppointments.ToList().Count > 0 ? db.ScheduleAppointments.ToList().Max(p => p.Id) : 0; if (added != null && added.Count > 0) { for (int i = 0; i < added.Count; i++) { intMax = db.ScheduleAppointments.ToList().Count > 0 ? db.ScheduleAppointments.ToList().Max(p => p.Id) : 0; var value = added[i]; DateTime startTime = Convert.ToDateTime(value.StartTime); DateTime endTime = Convert.ToDateTime(value.EndTime); ScheduleAppointment appoint = new ScheduleAppointment(); appoint.Id = intMax + 1; appoint.Subject = value.Subject; appoint.StartTime = startTime; appoint.EndTime = endTime; appoint.AllDay = value.AllDay; appoint.Recurrence = value.Recurrence; appoint.RecurrenceRule = value.RecurrenceRule; appoint.OwnerId = value.OwnerId; db.ScheduleAppointments.InsertOnSubmit(appoint); db.SubmitChanges(); } } ---------------------- ---------------------- ---------------------- return db.ScheduleAppointments.ToList(); } |