示例#1
0
        public void ProcessRequest(HttpContext context)
        {
            SchedulerAjaxData data;
            var dc = new SchedulerDataContext();

            if (context.Request.QueryString["recurring"] == null)
                data = new SchedulerAjaxData(dc.Events);
            else
                data = new SchedulerAjaxData(dc.Recurrings);

            context.Response.ContentType = "text/json";
            context.Response.Write(data.ToString());
        }
 protected bool deleteRelated(DataAction action, Recurring changedEvent, SchedulerDataContext context)
 {
     bool finished = false;
     if ((action.Type == DataActionTypes.Delete || action.Type == DataActionTypes.Update) && !string.IsNullOrEmpty(changedEvent.rec_type))
     {
         context.Recurrings.DeleteAllOnSubmit(from ev in context.Recurrings where ev.event_pid == changedEvent.id select ev);
     }
     if (action.Type == DataActionTypes.Delete && changedEvent.event_pid != 0)
     {
         Recurring changed = (from ev in context.Recurrings where ev.id == action.TargetId select ev).Single();
         changed.rec_type = "none";
         finished = true;
     }
     return finished;
 }
        protected bool deleteRelated(DataAction action, Recurring changedEvent, SchedulerDataContext context)
        {
            bool finished = false;

            if ((action.Type == DataActionTypes.Delete || action.Type == DataActionTypes.Update) && !string.IsNullOrEmpty(changedEvent.rec_type))
            {
                context.Recurrings.DeleteAllOnSubmit(from ev in context.Recurrings where ev.event_pid == changedEvent.id select ev);
            }
            if (action.Type == DataActionTypes.Delete && changedEvent.event_pid != 0)
            {
                Recurring changed = (from ev in context.Recurrings where ev.id == action.TargetId select ev).Single();
                changed.rec_type = "none";
                finished         = true;
            }
            return(finished);
        }
        public void ProcessRequest(HttpContext context)
        {
            var action = new DataAction(context.Request.Form);
            var data   = new SchedulerDataContext();

            try
            {
                var changedEvent = (Recurring)DHXEventsHelper.Bind(typeof(Recurring), context.Request.Form);//create model object from the request fields

                bool isFinished = deleteRelated(action, changedEvent, data);
                if (!isFinished)
                {
                    switch (action.Type)
                    {
                    case DataActionTypes.Insert:     // define here your Insert logic
                        data.Recurrings.InsertOnSubmit(changedEvent);

                        break;

                    case DataActionTypes.Delete:     // define here your Delete logic
                        changedEvent = data.Recurrings.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.Recurrings.DeleteOnSubmit(changedEvent);
                        break;

                    default:    // "update" // define here your Update logic
                        var updated = data.Recurrings.SingleOrDefault(ev => ev.id == action.SourceId);
                        DHXEventsHelper.Update(updated, changedEvent, new List <string>()
                        {
                            "id"
                        });


                        break;
                    }
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
                action          = insertRelated(action, changedEvent, data);
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
            context.Response.ContentType = "text/xml";
            context.Response.Write(new AjaxSaveResponse(action).ToString());
        }
示例#5
0
        public void ProcessRequest(HttpContext context)
        {
            SchedulerAjaxData data;
            var dc = new SchedulerDataContext();

            if (context.Request.QueryString["recurring"] == null)
            {
                data = new SchedulerAjaxData(dc.Events);
            }
            else
            {
                data = new SchedulerAjaxData(dc.Recurrings);
            }

            context.Response.ContentType = "text/json";
            context.Response.Write(data.ToString());
        }
        public void ProcessRequest(HttpContext context)
        {
            var action = new DataAction(context.Request.Form);
            var data = new SchedulerDataContext();

            try
            {

                var changedEvent = (Recurring)DHXEventsHelper.Bind(typeof(Recurring), context.Request.Form);//create model object from the request fields

                bool isFinished = deleteRelated(action, changedEvent, data);
                if (!isFinished)
                {
                    switch (action.Type)
                    {
                        case DataActionTypes.Insert: // define here your Insert logic
                            data.Recurrings.InsertOnSubmit(changedEvent);

                            break;
                        case DataActionTypes.Delete: // define here your Delete logic
                            changedEvent = data.Recurrings.SingleOrDefault(ev => ev.id == action.SourceId);
                            data.Recurrings.DeleteOnSubmit(changedEvent);
                            break;
                        default:// "update" // define here your Update logic
                            var updated = data.Recurrings.SingleOrDefault(ev => ev.id == action.SourceId);
                            DHXEventsHelper.Update(updated, changedEvent, new List<string>() { "id" });

                            break;
                    }
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
                action = insertRelated(action, changedEvent, data);
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
            context.Response.ContentType = "text/xml";
            context.Response.Write(new AjaxSaveResponse(action).ToString());
        }
示例#7
0
        public void ProcessRequest(HttpContext context)
        {
            var action = new DataAction(context.Request.Form);
            var data   = new SchedulerDataContext();

            try
            {
                var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), context.Request.Form);//create event object from request

                switch (action.Type)
                {
                case DataActionTypes.Insert:     // define here your Insert logic
                    data.Events.InsertOnSubmit(changedEvent);

                    break;

                case DataActionTypes.Delete:     // define here your Delete logic
                    changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                    data.Events.DeleteOnSubmit(changedEvent);
                    break;

                default:    // "update" // define here your Update logic
                    var updated = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                    //update "updated" object by changedEvent's values, 'id' should remain unchanged
                    DHXEventsHelper.Update(updated, changedEvent, new List <string>()
                    {
                        "id"
                    });
                    break;
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }

            context.Response.ContentType = "text/xml";
            context.Response.Write(new AjaxSaveResponse(action).ToString());
        }
示例#8
0
        public void ProcessRequest(HttpContext context)
        {
            var action = new DataAction(context.Request.Form);
            var data = new SchedulerDataContext();

            try
            {

                var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), context.Request.Form);//create event object from request

                switch (action.Type)
                {
                    case DataActionTypes.Insert: // define here your Insert logic
                        data.Events.InsertOnSubmit(changedEvent);

                        break;
                    case DataActionTypes.Delete: // define here your Delete logic
                        changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.Events.DeleteOnSubmit(changedEvent);
                        break;
                    default:// "update" // define here your Update logic
                        var updated = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        //update "updated" object by changedEvent's values, 'id' should remain unchanged
                        DHXEventsHelper.Update(updated, changedEvent, new List<string>() { "id" });
                        break;
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }

            context.Response.ContentType = "text/xml";
            context.Response.Write(new AjaxSaveResponse(action).ToString());
        }
 protected DataAction insertRelated(DataAction action, Recurring changedEvent, SchedulerDataContext context)
 {
     if (action.Type == DataActionTypes.Insert && changedEvent.rec_type == "none")
     {//insert_related
          action.Type = DataActionTypes.Delete;
     }
     return action;
 }
示例#10
0
 protected DataAction insertRelated(DataAction action, Recurring changedEvent, SchedulerDataContext context)
 {
     if (action.Type == DataActionTypes.Insert && changedEvent.rec_type == "none")
     {//insert_related
         action.Type = DataActionTypes.Delete;
     }
     return(action);
 }