public async Task<ActionResult> Details(Comment comment) { if (ModelState.IsValid) { var recipe = unitOfWork.RecipeRepository.GetById(comment.RecipeId); if (recipe == null) return RedirectToAction("Index"); comment.CreateDateTime = DateTime.Now; recipe.Comments.Add(comment); unitOfWork.RecipeRepository.Update(recipe); unitOfWork.Save(); var user = await IdentityHelpers.UserManager.FindByIdAsync(comment.UserId); var jsonComment = new CommentJsonViewModel { UserId = comment.UserId, UserName = user.UserName, CommentText = comment.CommentText, CreateDateTime = String.Format("{0:r}", comment.CreateDateTime), }; return Json(jsonComment); } return RedirectToAction("Index"); }
public static void StaticBroadCastComment(Comment comment, string id) { hubContext.Clients.AllExcept(new[] {id}).UpdateComments(comment); }