Example #1
0
        public async Task <IActionResult> CalculaJuros(decimal valorInicial, int quantidadeMeses)
        {
            var taxaJuros = await _taxaQueries.ObterTaxaDeJuros();

            ResultMessageResponse <decimal> result = await _mediator.Send(CalculaJurosCommand.Factory.Create(valorInicial, quantidadeMeses, taxaJuros));

            return(Ok(result));
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="next"></param>
        /// <returns></returns>
        public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
        {
            if (_domainNotification.HasNotifications)
            {
                context.HttpContext.Response.StatusCode  = (int)HttpStatusCode.BadRequest;
                context.HttpContext.Response.ContentType = "application/json";

                var erros = new ResultMessageResponse <string>(null, _domainNotification.GetNotifications().Select(GetMessageNotifications).ToArray());

                await context.HttpContext.Response.WriteAsync(JsonConvert.SerializeObject(erros));

                return;
            }

            await next();
        }
Example #3
0
        /// <summary>
        /// Retorna código HTTP de OK
        /// </summary>
        /// <returns></returns>
        public static ActionResult Ok2 <TResult>(this ControllerBase controllerBase, TResult obj)
        {
            ResultMessageResponse <TResult> result = obj;

            return(controllerBase.Ok(result));
        }