Beispiel #1
0
        protected virtual void VerificarPermissao(PermissaoTipo tipoPermissao)
        {
            var contemPermissao =
                _listaDePermissao?.Contains(tipoPermissao)
                ??
                true;

            Check.That(!contemPermissao, nameof(tipoPermissao), _messageSemPermissao);
        }
Beispiel #2
0
        public HttpResponseMessage Response(PermissaoTipo tipo, Func <object> funcao)
        {
            try
            {
                VerificarPermissao(tipo);

                var conteudo = funcao.Invoke();

                var statusCode = conteudo is ErroOutModel ? HttpStatusCode.BadRequest
                    : conteudo is NotFoundOutModel ? HttpStatusCode.NotFound
                    : HttpStatusCode.OK
                ;

                return(Request.CreateResponse(statusCode, MessageHandler.CreateMessage(conteudo: conteudo)));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, MessageHandler.CreateMessage(ex)));
            }
        }