public ActionResult EditComment([Bind(Include = "SuggestionId, Description, CreatingTime, UserId, CommentId")] SuggestionCommentView comment) { SuggestionComment suggestionComment = db.SuggestionComments.Find(comment.CommentId); suggestionComment.Description = comment.Description; if (ModelState.IsValid) { db.Entry(suggestionComment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details", new { id = comment.SuggestionId })); } return(RedirectToAction("Details", new { id = comment.SuggestionId, message = "Your comment is not editted successfully" })); }
protected UserSuggestion MakeAUserSuggestion(Suggestion suggestion, string flag = "index") { UserSuggestion userSuggestion = new UserSuggestion(); userSuggestion.UserId = suggestion.UserId; userSuggestion.SuggestionId = suggestion.SuggestionId; userSuggestion.FirstName = suggestion.User.FirstName; userSuggestion.LastName = suggestion.User.LastName; userSuggestion.Title = suggestion.Title; userSuggestion.Description = suggestion.Description; userSuggestion.CreatingTime = suggestion.CreatingTime; userSuggestion.Vote = suggestion.Vote; userSuggestion.GroupName = suggestion.GroupName; userSuggestion.NumComments = suggestion.SuggestionComments.Count; userSuggestion.Email = suggestion.User.Email; foreach (var upvote in suggestion.SuggestionUpvotes) { userSuggestion.SuggestionUpvotes.Add(upvote); } if (flag == "detail") { foreach (var comment in suggestion.SuggestionComments) { SuggestionCommentView suggestionCommentView = new SuggestionCommentView(); suggestionCommentView.CommentId = comment.CommentId; suggestionCommentView.UserId = comment.UserId; suggestionCommentView.UserName = comment.User.LastName + ", " + comment.User.FirstName; suggestionCommentView.Email = comment.User.Email; suggestionCommentView.SuggestionId = comment.SuggestionId; suggestionCommentView.Description = comment.Description; suggestionCommentView.CreatingTime = comment.CreatingTime; userSuggestion.SuggestionCommentViews.Add(suggestionCommentView); } } return(userSuggestion); }