コード例 #1
0
        public ActionResult CustomSave(Event changedEvent, FormCollection actionValues)
        {
            var action = new DataAction(DataActionTypes.Update, changedEvent.id, changedEvent.id);
            if (actionValues["actionButton"] != null)
            {
                DHXSchedulerModelsDataContext data = new DHXSchedulerModelsDataContext();
                try
                {
                    if (actionValues["actionButton"] == "Save")
                    {

                        if (data.Events.SingleOrDefault(ev => ev.id == action.SourceId) != null)
                        {
                            var eventToUpdate = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                            DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" });
                        }
                        else
                        {
                            action.Type = DataActionTypes.Insert;
                            data.Events.InsertOnSubmit(changedEvent);
                        }
                    }else if(actionValues["actionButton"] == "Delete"){
                        action.Type = DataActionTypes.Delete;
                        changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.Events.DeleteOnSubmit(changedEvent);
                    }
                    data.SubmitChanges();
                }

                catch
                {
                    action.Type = DataActionTypes.Error;
                }
            }
            else
            {
                action.Type = DataActionTypes.Error;
            }

            return (new SchedulerFormResponseScript(action, changedEvent));
        }
コード例 #2
0
 partial void DeleteEvent(Event instance);
コード例 #3
0
 partial void UpdateEvent(Event instance);
コード例 #4
0
 partial void InsertEvent(Event instance);
コード例 #5
0
        public ContentResult NativeSave(Event changedEvent, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            DHXSchedulerModelsDataContext data = new DHXSchedulerModelsDataContext();
            try
            {
                switch (action.Type)
                {
                    case DataActionTypes.Insert:
                        data.Events.InsertOnSubmit(changedEvent);
                        break;
                    case DataActionTypes.Delete:
                        changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.Events.DeleteOnSubmit(changedEvent);
                        break;
                    default:// "update"
                        var eventToUpdate = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" });
                        break;
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }

            return (new AjaxSaveResponse(action));
        }
コード例 #6
0
 public ActionResult LightboxControl(Event ev)
 {
     var context = new DHXSchedulerModelsDataContext();
     var current = context.Events.SingleOrDefault(e => e.id == ev.id);
     if (current == null)
         current = ev;
     return View(current);
 }