public ActionResult Handle(PowerTablesData data, IResponseModifiersApplier responseModifiers) { // queryable reveals here var mapped = data.Mapped.Value; PowerTablesResponse ptr = new PowerTablesResponse() { PageIndex = data.CurrentPage, ResultsCount = data.ResultsCount, Data = data.Configuration.EncodeResults(mapped), AdditionalData = new Dictionary <string, object>(), Success = false }; try { responseModifiers.ApplyResponseModifiers(data, ptr); } catch (Exception ex) { ptr.FormatException(ex); } ptr.Success = true; return(new JsonNetResult() { Data = ptr, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public void ModifyResponse(PowerTablesData data, PowerTablesResponse response) { if (_action != null) { _action(data, response); } }
public async Task <ActionResult> HandleAsync(PowerTablesData data, IResponseModifiersApplier responseModifiers) { PowerTablesData <TSourceData, TTargetData> typedData = new PowerTablesData <TSourceData, TTargetData>(data); TResponse response; if (_asynchandlerMethod != null) { response = await _asynchandlerMethod(typedData).ConfigureAwait(false); } else { response = _handlerMethod(typedData); } if (typeof(PowerTablesResponse).IsAssignableFrom(typeof(TResponse))) { responseModifiers.ApplyResponseModifiers(data, (PowerTablesResponse)(object)response); } var o = response as ActionResult; if (o != null) { return(o); } return(new JsonNetResult() { Data = response, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult Handle(PowerTablesData data, IResponseModifiersApplier responseModifiers) { if (_handlerMethod == null) { throw new Exception("This is asynchronous command handler. Please use it with .HandleAsync, not .Handle."); } PowerTablesData <TSourceData, TTargetData> typedData = new PowerTablesData <TSourceData, TTargetData>(data); var response = _handlerMethod(typedData); if (typeof(PowerTablesResponse).IsAssignableFrom(typeof(TResponse))) { responseModifiers.ApplyResponseModifiers(data, (PowerTablesResponse)(object)response); } var o = response as ActionResult; if (o != null) { return(o); } return(new JsonNetResult() { Data = response, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult Handle(PowerTablesData data, IResponseModifiersApplier responseModifiers) { var ar = SelectCheckboxes(data).ToArray(); return(new JsonNetResult() { Data = ar, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public OperationResult Delete(PowerTablesData <Toy, Row> request) { int[] selectedIds = request.Request.GetSelectionIds <int>(); var rc = Data.SourceData.RemoveAll(c => selectedIds.Contains(c.Id)); return(new OperationResult() { Message = String.Format("All went ok. {0} items removed", rc), Success = true }); }
private IQueryable <string> SelectCheckboxes(PowerTablesData data) { var column = data.Request.Query.AdditionalData["SelectionColumn"]; var columnProp = data.Configuration.SourceType.GetProperty(column); var selection = LambdaHelpers.MemberExpression(columnProp); var q = ReflectionCache.CallSelect(data.Ordered, selection, data.Configuration.SourceType, columnProp.PropertyType); return(q.Cast <object>().Select(c => c.ToString())); }
private TableUpdateResult RemoveSelected(PowerTablesData <Toy, Row> arg) { EditionResult er = new EditionResult(); var editResultWrapper = new EditionResultWrapper <Row>(er); var selected = arg.Request.GetSelectionIds <int>(); foreach (var i in selected) { editResultWrapper.Adjustments.Remove(new Row() { Id = i }); } return(new TableUpdateResult(editResultWrapper)); }
public void ModifyResponse(PowerTablesData data, PowerTablesResponse response) { TotalResponse tr = new TotalResponse() { TotalsForColumns = new Dictionary <string, object>() }; var gData = new PowerTablesData <TSourceData, TTableData>(data); foreach (var keyValuePair in _calculator.Calculators) { var result = keyValuePair.Value.DynamicInvoke(gData); tr.TotalsForColumns[keyValuePair.Key] = result; } response.AdditionalData[TotalExtensions.PluginId] = tr; }
private TableUpdateResult UpdateSelected(PowerTablesData <Toy, Row> arg) { var form = arg.Request.ConfirmationForm <SimpleConfirmationModel>(); EditionResult er = new EditionResult(); var editResultWrapper = new EditionResultWrapper <Row>(er); var selected = arg.Request.GetSelectionIds <int>(); foreach (var i in selected) { var data = Data.SourceData.Single(c => c.Id == i); data.ToyName = form.ToyName; data.GroupType = form.ToyType.Value; editResultWrapper.Adjustments.AddOrUpdate(arg.Configuration.Map(data)); } return(new TableUpdateResult(editResultWrapper)); }
private void EditData(PowerTablesData <Toy, Row> powerTablesData, EditionResultWrapper <Row> edit) { edit.ConfirmedObject.Name = edit.ConfirmedObject.Name + " - Edited"; edit.ConfirmedObject.TypeOfToy = ToyType.Dolls; var idsToUpdate = new[] { 2750, 2747, 2744 }; var src = Data.SourceData.Where(c => idsToUpdate.Contains(c.Id)).ToArray(); var mapped = powerTablesData.Configuration.MapRange(src); foreach (var row in mapped) { row.Name = "UFO edited this label"; row.IsPaid = true; } edit.Adjustments.AddOrUpdateAll(mapped); edit.Message(TableMessage.User("info", "Objects were updated", "Successful")); }
public ActionResult Handle(PowerTablesData data, IResponseModifiersApplier responseModifiers) { if (_handlerMethod == null) { throw new Exception("This is asynchronous command handler. Please use it with .HandleAsync, not .Handle."); } PowerTablesData <TSourceData, TTargetData> typedData = new PowerTablesData <TSourceData, TTargetData>(data); var editionResult = new EditionResult(); var wrapper = new EditionResultWrapper <TTargetData>(editionResult); wrapper.Confirm(data.Request.RetrieveAdditionalObject <TTargetData>(EditorExtensions.EditAdditionalDataKey)); _handlerMethod(typedData, wrapper); return(new JsonNetResult() { Data = editionResult, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public async Task <ActionResult> HandleAsync(PowerTablesData data, IResponseModifiersApplier responseModifiers) { PowerTablesData <TSourceData, TTargetData> typedData = new PowerTablesData <TSourceData, TTargetData>(data); var editionResult = new EditionResult(); var wrapper = new EditionResultWrapper <TTargetData>(editionResult); wrapper.Confirm(data.Request.RetrieveAdditionalObject <TTargetData>(EditorExtensions.EditAdditionalDataKey)); if (_asynchandlerMethod != null) { await _asynchandlerMethod(typedData, wrapper).ConfigureAwait(false); } else { _handlerMethod(typedData, wrapper); } return(new JsonNetResult() { Data = editionResult, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public Task <ActionResult> HandleAsync(PowerTablesData data, IResponseModifiersApplier responseModifiers) { return(Task.FromResult(Handle(data, responseModifiers))); }
public FileResult DownloadSome(PowerTablesData <Toy, Row> request) { return(File(@"K:\Temp\mr-101-20150608-002.csv", "text/csv")); }