public ContentResult CustomFormSave(DataAction action, ValidEvent changedEvent, FormCollection actionValues)
        {
            if (actionValues["actionType"] != null)
            {
                var actionType = actionValues["actionType"].ToLower();
                var data = new DHXSchedulerDataContext();
                try
                {
                    if (actionType == "save")
                    {

                        if (data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId) != null)
                        {
                            //update event
                            var eventToUpdate = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);

                            DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" });

                            action.Type = DataActionTypes.Update;
                        }
                        else
                        {
                            //create event
                            data.ValidEvents.InsertOnSubmit(changedEvent);
                            action.Type = DataActionTypes.Insert;
                        }
                    }
                    else if (actionType == "delete")
                    {

                        changedEvent = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.ValidEvents.DeleteOnSubmit(changedEvent);

                        action.Type = DataActionTypes.Delete;
                    }
                    data.SubmitChanges();
                }

                catch (Exception e)
                {
                    action.Type = DataActionTypes.Error;
                }
            }

            return (new SchedulerFormResponseScript(action, changedEvent));
        }
 partial void DeleteValidEvent(ValidEvent instance);
 partial void UpdateValidEvent(ValidEvent instance);
 partial void InsertValidEvent(ValidEvent instance);
 public ActionResult LightboxControl(ValidEvent ev)
 {
     var context = new DHXSchedulerDataContext();
     var current = context.ValidEvents.SingleOrDefault(e => e.id == ev.id);
     if (current == null)
         current = ev;
     return View(current);
 }
        public ContentResult NativeSave(DataAction action, ValidEvent changedEvent, FormCollection actionValues)
        {
            var data = new DHXSchedulerDataContext();
            try
            {
                switch (action.Type)
                {
                    case DataActionTypes.Insert:
                        data.ValidEvents.InsertOnSubmit(changedEvent);
                        break;
                    case DataActionTypes.Delete:
                        changedEvent = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.ValidEvents.DeleteOnSubmit(changedEvent);
                        break;
                    default:// "update"
                        var eventToUpdate = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                        DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" });
                        break;
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch (Exception a)
            {
                action.Type = DataActionTypes.Error;
            }

            return (new AjaxSaveResponse(action));
        }
Beispiel #7
0
 partial void DeleteValidEvent(ValidEvent instance);
Beispiel #8
0
 partial void UpdateValidEvent(ValidEvent instance);
Beispiel #9
0
 partial void InsertValidEvent(ValidEvent instance);