Exemplo n.º 1
0
        public ActionResult DeleteComment(Comment comment)
        {
            var c = _ctx.Comments.FirstOrDefault(x => x.ID == comment.ID);
            if (c != null)
            {
                var id = c.Article.Page.ID;
                _ctx.Comments.Remove(c);
                Save();
                TempData["message"] = new List<string> { "Kommentaren är borttagen" };
                if (id > 0)
                    return Redirect("/admin/page/" + id);

            }
            return Redirect("/admin");
        }
Exemplo n.º 2
0
 public ActionResult Comment(Comment comment, string url, int articleID)
 {
     if (!string.IsNullOrEmpty(comment.Text))
     {
         var article = _ctx.Articles.Find(articleID);
         comment.Date = DateTime.Now;
         comment.User = _site.Users.First(x => x.UserName == User.Identity.Name);
         article.Comments.Add(comment);
         _ctx.SaveChanges();
     }
     return Redirect(url);
 }