public ViewResult makecomment(Homelist homelistmodelview, int id) { var post = _post.getallposts().FirstOrDefault(c => c.p_id == id); var Id = 3; id++; var newcomment = new Icomment() { commentid = Id, comment = homelistmodelview.comment, commentby = homelistmodelview.C_user, Like = 0, }; post.comments.Add(newcomment); homelistmodelview.newpost = post; return(View("comment", homelistmodelview)); }
public ViewResult sharecomment(int id, int cid, Homelist homelst) { Homelist homelist = new Homelist(); homelist.newpost = _post.getallposts().FirstOrDefault(c => c.p_id == id); var Id = homelist.newpost.comments.Max(c => c.commentid) + 1; var oldcomment = homelist.newpost.comments.Find(c => c.commentid == cid); var comment = new Icomment() { commentid = Id, comment = oldcomment.comment, commentby = "Shared by: " + homelst.S_user + "& commented by: " + oldcomment.commentby, }; homelist.newpost.comments.Add(comment); return(View("comment", homelist)); }