public ActionResult AddPostComment(int id) { var model = new BlogPostCommentAddViewModel(); model.BlogPostId = id; model.IsAnonymous = !User.Identity.IsAuthenticated; return PartialView("_AddPostComment", model); }
public ActionResult AddPostComment(int id) { var model = new BlogPostCommentAddViewModel(); model.BlogPostId = id; model.IsAnonymous = !User.Identity.IsAuthenticated; return(PartialView("_AddPostComment", model)); }
public ActionResult Edit(BlogPostCommentAddViewModel model) { if (ModelState.IsValid) { blogPostCommentService.AddOrUpdate(model); return(RedirectToAction("Index") .WithSuccess(string.Format("The comment \"{0}\" has been updated".TA(), model.Name))); } return(View(model)); }
public ActionResult AddPostComment(BlogPostCommentAddViewModel model) { // var comment = Mapper.Map<BlogPostComment>(model); if (User.Identity.IsAuthenticated) { model.UserId = currentUser.User.Id; model.Name = currentUser.User.FirstName; model.Email = currentUser.User.Email; } blogPostCommentService.AddOrUpdate(model); var action = RedirectToAction("Post", new {id = model.BlogPostId}); return action.WithSuccess(string.Format("The comment has been added".TA())); }
public ActionResult AddPostComment(BlogPostCommentAddViewModel model) { // var comment = Mapper.Map<BlogPostComment>(model); if (User.Identity.IsAuthenticated) { model.UserId = currentUser.User.Id; model.Name = currentUser.User.FirstName; model.Email = currentUser.User.Email; } blogPostCommentService.AddOrUpdate(model); var action = RedirectToAction("Post", new { id = model.BlogPostId }); return(action.WithSuccess(string.Format("The comment has been added".TA()))); }
public BlogPostComment AddOrUpdate(BlogPostCommentAddViewModel model) { BlogPostComment comment; if (model.Id == 0) { comment = Mapper.Map <BlogPostComment>(model); db.BlogPostComments.Add(comment); } else { comment = Find(model.Id); Mapper.Map(model, comment); } db.SaveChanges(); return(comment); }
public BlogPostComment AddOrUpdate(BlogPostCommentAddViewModel model) { BlogPostComment comment; if (model.Id == 0) { comment = Mapper.Map<BlogPostComment>(model); db.BlogPostComments.Add(comment); } else { comment = Find(model.Id); Mapper.Map(model, comment); } db.SaveChanges(); return comment; }
public ActionResult Edit(BlogPostCommentAddViewModel model) { if (ModelState.IsValid) { blogPostCommentService.AddOrUpdate(model); return RedirectToAction("Index") .WithSuccess(string.Format("The comment \"{0}\" has been updated".TA(), model.Name)); } return View(model); }