public ActionResult DeleteComment(DeleteCommentVM delete) { CommentRepo repo = new CommentRepo(); Comment deletedComment = repo.GetById(Convert.ToInt32(delete.Id)); repo.Delete(deletedComment); return(RedirectToAction("Details", "TaskManagement", new { id = Convert.ToInt32(deletedComment.taskId) })); }
public ActionResult DeleteComment(int id) { if (AuthenticationManager.LoggedUser == null) { return(RedirectToAction("Login", "Home")); } CommentRepo repoComment = new CommentRepo(); Comment comment = repoComment.GetById(id); TaskRepo repo = new TaskRepo(); Task task = repo.GetById(comment.taskId); if (comment.commentCreatorId == AuthenticationManager.LoggedUser.Id || task.creatorId == AuthenticationManager.LoggedUser.Id) { UserRepo repoUser = new UserRepo(); List <User> users = repoUser.GetAll().ToList(); DeleteCommentVM delete = new DeleteCommentVM(); delete.users = new List <User>(); delete.Id = comment.Id; delete.Tittle = comment.commentTittle; delete.Content = comment.commentContent; delete.CreatorId = comment.commentCreatorId; delete.TaskId = comment.taskId; delete.Date = comment.Date; foreach (var item in users) { delete.users.Add(item); } return(View(delete)); } else { return(RedirectToAction("Details", "TaskManagement", new { id = comment.taskId })); } }