public async Task <IActionResult> GetRemoved() { var comments = await _commentRepository.GetAllAsync(c => c.IsDeleted && c.IsConfirmed, c => c.Recipe, c => c.User); if (comments == null) { return(NotFound()); } var dto = _mapper.Map <IEnumerable <CommentIndexDto> >(comments); foreach (var item in dto) { var commentSelected = comments.FirstOrDefault(x => x.Id == item.Id); item.UserName = commentSelected.User.UserName; item.RecipeName = commentSelected.Recipe.FoodName; } var model = new CommentIndexViewModel { Comments = dto }; return(View(model)); }
public IActionResult Create(int id) { var commVM = new CommentIndexViewModel(); commVM.PostComments = _commentRepo.GetCommentsByPostId(id); return(View(commVM)); }
public IActionResult Edit(int id, int postId) { CommentIndexViewModel commVM = new CommentIndexViewModel(); commVM.Comment = _commentRepo.GetCommentById(id); commVM.Comment.PostId = postId; return(View(commVM)); }
// GET: CommentController/Create public ActionResult Create(int id) { CommentIndexViewModel vm = new CommentIndexViewModel(); vm.PostComments = _commentRepo.GetCommentsByPostId(id); vm.Post = _postRepo.GetPublisedPostById(id); return(View(vm)); }
public IActionResult Index(int id) { var comments = _commentRepo.GetCommentsByPostId(id); var post = _postRepo.GetPublishedPostById(id); var commVM = new CommentIndexViewModel() { PostComments = comments, Post = post, }; return(View(commVM)); }
public ActionResult Delete(int id, CommentIndexViewModel vm) { try { _commentRepo.DeleteComment(id); return(RedirectToAction("Index", "Post")); } catch (Exception ex) { return(View(vm)); } }
private CommentIndexViewModel CreateIndexVM(int id) { var vm = new CommentIndexViewModel(); Post post = _postRepository.GetPublishedPostById(id); List <Comment> comments = _commentRepository.getAllByPost(id); vm.Post = post; vm.Comments = comments; return(vm); }
// GET: CommentController public ActionResult Index(int id) { var comments = _commentRepo.GetCommentsByPostId(id); Post post = _postRepo.GetPublisedPostById(id); int profileId = GetCurrentUserProfileId(); var userProfile = _userRepo.GetUserById(profileId); var vm = new CommentIndexViewModel() { PostComments = comments, Post = post, UserProfile = userProfile }; return(View(vm)); }
// GET: CommentController/Delete/5 public ActionResult Delete(int id) { int userProfileId = GetCurrentUserProfileId(); var comments = _commentRepo.GetCommentsByPostId(id); Post post = _postRepo.GetPublisedPostById(id); //var comment = _commentRepo.GetUserCommentById(id, userProfileId); var vm = new CommentIndexViewModel() { PostComments = comments, Post = post }; return(View(vm)); }
public IActionResult Edit(CommentIndexViewModel commVM, int id) { try { commVM.Comment.Id = id; commVM.Comment.PostId = _commentRepo.GetCommentById(id).PostId; commVM.Comment.UserProfileId = GetCurrentUserProfileId(); commVM.Comment.CreateDateTime = DateTime.Now; _commentRepo.EditComment(commVM.Comment); return(RedirectToAction("Index", new { id = commVM.Comment.PostId })); } catch { return(View(commVM)); } }
public ActionResult Create(CommentIndexViewModel vm, int id) { try { vm.Comment.UserProfileId = GetCurrentUserProfileId(); vm.Comment.PostId = id; vm.PostComments = _commentRepo.GetCommentsByPostId(id); vm.Comment.CreateDateTime = DateTime.Now; _commentRepo.AddComment(vm.Comment); return(RedirectToAction("Index", new { id = id })); } catch (Exception ex) { return(View(vm)); } }