public async Task NewComment(string currentUser, string commentFor, int commentForId, string commentContent) { Comment comment = new Comment { CreatedBy = currentUser, For = commentFor, ForId = commentForId, Content = commentContent, DateAdded = DateTime.Now }; repository.SaveComment(comment); if (commentFor == "Course") { _ = ShowCourseCommentNotification(currentUser, commentForId); } else if (commentFor == "Video") { _ = ShowVideoCommentNotification(currentUser, commentForId); } AppUser user = userManager.Users.FirstOrDefault(u => u.Id == currentUser); await Clients.All.SendAsync("PostNewComment", comment.For, comment.ForId, comment.DateAdded, comment.Content, comment.Id, comment.CreatedBy, user.FirstName, user.LastName, user.ProfilePhotoUrl); }
public ActionResult NewComment(Comment model, string returnUrl) { model.DateAdded = DateTime.Now; repository.SaveComment(model); return(Redirect(returnUrl)); }