Example #1
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var notificacaoes = await Task.FromResult(_notificador.ObterNotificacao());

            notificacaoes.ForEach(a => ViewData.ModelState.AddModelError(string.Empty, a.Message));
            return(View());
        }
        protected ActionResult CustomResponse(object result = null)
        {
            if (OperacaoValida())
            {
                return(Ok(new
                {
                    success = true,
                    data = result
                }));
            }

            return(BadRequest(new
            {
                success = false,
                data = _notificar.ObterNotificacao().Select(n => n.Mensagem)
            }));
        }
        protected ActionResult Result(object obj = null)
        {
            // validacoes OK
            if (!_notificador.TemNotificacao())
            {
                return(Ok(new
                {
                    sucesso = true,
                    data = obj
                }));
            }


            // Validações não OK

            return(BadRequest(new
            {
                sucesso = false,
                erros = _notificador.ObterNotificacao().Select(n => n.Mensagem)
            }));
        }