Ejemplo n.º 1
0
        public ActionResult SalvarAprovarPost(string guid)
        {
            try
            {
                if (string.IsNullOrEmpty(guid))
                {
                    return(View());
                }

                var postEntity = _postService.BuscarPorGuid(guid);

                if (postEntity == null)
                {
                    return(Json(new
                    {
                        message = "Post não encontrado para realizar a operação. Tente mais tarde.",
                        result = "ERRO",
                    }, JsonRequestBehavior.AllowGet));
                }

                _postService.SetPostAprovado(postEntity);

                bool resultado = _postService.Atualizar(postEntity);

                if (resultado)
                {
                    return(Json(new
                    {
                        message = "Post aprovado com sucesso!",
                        result = "OK",
                    }, JsonRequestBehavior.AllowGet));
                }

                return(MensagemDeErro());
            }
            catch (Exception)
            {
                return(MensagemDeErro());
            }
        }