public ActionResult saveComment(BlogEntryCommentViewModel model)
 {
     if (ModelState.IsValid)
     {
         BlogEntryComment comment = new BlogEntryComment(new { model.CommentText, model.Author });
         using (var db = new Datalayer.Models.DatabaseContext())
         {
             db.BlogEntryComments.Add(model);
             db.BlogEntries.BlogEntryComment.Comment.Add(model);
             db.SaveChanges();
         }
     }
 }
Exemplo n.º 2
0
 public ActionResult saveComment(BlogEntryCommentViewModel model)
 {
     if (ModelState.IsValid)
     {
         BlogEntryComment comment = new BlogEntryComment {
             CommentText = model.CommentText, Author = model.Author
         };
         using (var db = new Datalayer.Models.DatabaseContext())
         {
             db.BlogEntryComments.Add(comment);
             var blog = db.BlogEntries.Find(model.BlogID);
             blog.Comments.Add(comment);
             db.SaveChanges();
         }
     }
     return(RedirectToAction("BlogEntry", "BlogEntries"));
 }