public ActionResult EditSubComment(SubCommentDto subcommentDto) { SubComment subcomment = db.SubComments.FirstOrDefault(s => s.Id == subcommentDto.SubCommentId); subcomment.Text = subcommentDto.Text; db.SaveChanges(); return(Json(1, JsonRequestBehavior.AllowGet)); }
public ActionResult SaveSubComment(SubCommentDto subCommentDto) { var userName = Session["userName"] as string; User user = db.Users.FirstOrDefault(us => us.UserName.Equals(userName)); Comment comment = db.Comments.FirstOrDefault(s => s.Id == subCommentDto.CommentId); SubComment subComment = new SubComment { Text = subCommentDto.Text, CommentId = subCommentDto.CommentId, UserId = user.Id }; db.SubComments.Add(subComment); db.SaveChanges(); int SubCommentId = db.SubComments.Max(s => s.Id); SubCommentDto result = new SubCommentDto { UserNameComment = userName, UrlPersonal = "/Home/Personal?id=" + user.Id.ToString(), UserName = comment.User.UserName, LikeNumber = 0, NameOfUser = user.Name, Text = subCommentDto.Text, Avatar = user.Avatar, SubCommentId = SubCommentId }; if (user.Id != comment.User.Id) { Notification noti = new Notification { UserId = comment.User.Id, PostId = comment.Post.Id, NameOfUser = user.Name, Avatar = user.Avatar, TextNoti = "Đã trả lời bình luận của bạn", ClassIconName = "far fa-comments", NotificationState = false }; db.Notifications.Add(noti); } NotifiDto notiDto = new NotifiDto { NameOfUser = user.Name, SubjectName = comment.Post.Subject.Name, Avatar = user.Avatar, SubjectId = comment.Post.SubjectId, TimeNotifi = comment.Post.CreatedDate, PostId = comment.Post.Id, TextNoti = "Đã trả lời bình luận của bạn" }; db.SaveChanges(); return(Json(new { result, notiDto }, JsonRequestBehavior.AllowGet)); }
public void EditSubComment(string groupName, SubCommentDto subcommentDto) { Clients.All.EditSubComment(groupName, subcommentDto); }
public void CreateSubCommentNew(string myuserName, string groupName, int commentId, SubCommentDto subCommentDto, NotifiDto notiDto) { Clients.All.CreateSubComment(groupName, commentId, subCommentDto); if (myuserName != subCommentDto.UserName) { List <string> listId = GetListConnectIdByUserName("No value", subCommentDto.UserName); Clients.Clients(listId).UpdateNotiRealtime(notiDto); } }