Exemplo n.º 1
0
        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
            });
        }
Exemplo n.º 2
0
        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
            });
        }