コード例 #1
0
        public IActionResult OnGetComentar(long IdUsuario, long IdPost, string Texto, long IdComentario)
        {
            if (string.IsNullOrEmpty(Texto))
            {
                return(new JsonResult(new { OK = false }, new Newtonsoft.Json.JsonSerializerSettings()
                {
                }));
            }

            if (HttpContext.Session.GetObjectFromJson <Usuario>("USUARIO") == null)
            {
                return(RedirectToPage("/Login"));
            }

            if (IdPost > 0)
            {
                using (PrivacyContext context = new PrivacyContext())
                {
                    bool comentou = PostModel.Comentar(IdUsuario, IdPost, Texto, IdComentario);

                    if (comentou)
                    {
                        return(new JsonResult(new { OK = true }, new Newtonsoft.Json.JsonSerializerSettings()
                        {
                        }));
                    }

                    else
                    {
                        return(new JsonResult(new { OK = false }, new Newtonsoft.Json.JsonSerializerSettings()
                        {
                        }));
                    }
                }
            }

            return(null);
        }