Пример #1
0
        public ActionResult Autenticar(UsuarioModel model)
        {
            var mensagens = new Mensagens();

            string msgExibicao = string.Empty;
            string msgAnalise  = string.Empty;

            var resultService = new ResultModel <UsuarioModel>();

            resultService.Status = false;

            try
            {
                resultService = _usuarioBusiness.Autenticar(model);
                model         = resultService.Value;

                if (resultService.Status)
                {
                    session.AddModelToSession(model, sessionName);
                }

                msgExibicao = resultService.Message;
                msgAnalise  = !resultService.Status ? "Falha" : string.Empty;
            }
            catch (Exception ex)
            {
                msgExibicao = "Falha ao autenticar!";
                msgAnalise  = ex.ToString();
            }

            var mensagensRetorno = mensagens.ConfiguraMensagemRetorno(msgExibicao, msgAnalise);

            return(Json(new { mensagensRetorno }, JsonRequestBehavior.AllowGet));
        }