public void EditGridComment(CommentViewModel model) { if (ModelState.IsValid) { _commentService.UpdateComment(model.ToBllComment()); } }
public ActionResult CreateComment(int photoId, string comment, int page) { var user = accountService.GetUserByUserName(User.Identity.Name)?.ToMvcUser(); var comm = new CommentViewModel() { PhotoId = photoId, Description = comment, UserId = user.Id, DateOfSending = DateTime.Now }; photoService.CreateComment(comm.ToBllComment()); var paging = photoService.GetCommentsPaging(photoId, commentPageSize, page, true).ToMvcCommentsPaging(); if (Request.IsAjaxRequest()) { return(PartialView("_Comments", paging)); } var photo = photoService.GetById(photoId)?.ToMvcPhoto(); user = accountService.GetByUserId(photo.UserId)?.ToMvcUser(); var photoDetail = new PhotoCommentViewModel { User = user, Photo = photo, CommentPaging = paging }; return(View("PhotoDetails", photoDetail)); }
public ActionResult AddComment(CommentViewModel model, int ArticleId) { model.PublicationDate = DateTime.Now; model.UserId = Convert.ToInt32(HttpContext.Profile.GetPropertyValue("Id")); model.ArticleId = ArticleId; commentService.Create(model.ToBllComment()); return(GetComments(model.ArticleId)); }
public ActionResult EditComment(CommentViewModel model) { if (ModelState.IsValid) { _commentService.UpdateComment(model.ToBllComment()); return(RedirectToAction("AdminPanel", "Admin")); } return(View(model)); }
public ActionResult EditComment(CommentViewModel comment) { if (comment.Id == 0) { commentService.Create(comment.ToBllComment()); } else { commentService.Update(comment.ToBllComment()); } if (Request.IsAjaxRequest()) { return(RedirectToAction("GetCommentsByPost", "Comment", new { postId = comment.PostId })); } return(RedirectToAction("GetPost", "Home", new { postId = comment.PostId })); }
public ActionResult Create(CommentViewModel comment) { if (!ModelState.IsValid) { return(View(comment)); } CommentViewModel model = new CommentViewModel { Description = comment.Description, CreatedOn = DateTime.Now, Name = comment.Name, PostId = comment.PostId }; commentService.CreateComment(model.ToBllComment()); return(RedirectToAction("", "Post")); }