コード例 #1
0
        public async Task <IActionResult> CallRest <D, T, G, A>(Func <T, G, A, Task <OperationResult <D> > > result, T input, G input1, A input2)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                OperationResult <D> res = await result(input, input1, input2);

                if (res.Succeeded)
                {
                    return(Ok(res.SuccessResult));
                }
                return(BadRequest(res.Errors));
            }
            catch (Exception e)
            {
                Loki.ExceptionError(e);
                HttpContext.Items["Exception"] = e;
                if (RethrowException)
                {
                    throw;
                }
                return(BadRequest(OperationResult.Fail <D>(GeneralErrorCode, GeneralErrorMessage).Errors));
            }
        }
コード例 #2
0
        public IActionResult CallRest <D, T>(Func <T, OperationResult <D> > result, T input)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                OperationResult <D> res = result(input);
                if (res.Succeeded)
                {
                    return(Ok(res.SuccessResult));
                }
                return(BadRequest(res.Errors));
            }
            catch (Exception e)
            {
                Loki.ExceptionError(e);
                HttpContext.Items["Exception"] = e;
                if (RethrowException)
                {
                    throw;
                }

                return(BadRequest(OperationResult.Fail <D>(GeneralErrorCode, GeneralErrorMessage).Errors));
            }
        }
コード例 #3
0
        public IActionResult CallRest <D, T, G, A, B, C, E, F, H, I, J>(Func <T, G, A, B, C, E, F, H, I, J, OperationResult <D> > result, T input, G input1, A input2, B input3, C input4, E input5, F input6, H input7, I input8, J input9)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                OperationResult <D> res = result(input, input1, input2, input3, input4, input5, input6, input7, input8, input9);
                if (res.Succeeded)
                {
                    return(Ok(res.SuccessResult));
                }
                return(BadRequest(res.Errors));
            }
            catch (Exception e)
            {
                Loki.ExceptionError(e);
                HttpContext.Items["Exception"] = e;
                if (RethrowException)
                {
                    throw;
                }

                return(BadRequest(OperationResult.Fail <D>(GeneralErrorCode, GeneralErrorMessage).Errors));
            }
        }
コード例 #4
0
        public async Task <IActionResult> CallRest <D>(Func <Task <OperationResult <D> > > result)
        {
            try
            {
                OperationResult <D> res = await result();

                if (res.Succeeded)
                {
                    return(Ok(res.SuccessResult));
                }
                return(BadRequest(res.Errors));
            }
            catch (Exception e)
            {
                Loki.ExceptionError(e);
                HttpContext.Items["Exception"] = e;
                if (RethrowException)
                {
                    throw;
                }
                return(BadRequest(OperationResult.Fail <D>(GeneralErrorCode, GeneralErrorMessage).Errors));
            }
        }