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)); }
partial void DeleteEvent(Event instance);
partial void UpdateEvent(Event instance);
partial void InsertEvent(Event instance);
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)); }
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); }