public Comment AddCmmnt(string Id,Comment cmt) { //IMongoQuery query = Query.EQ("_id", Id); cmt.commentID = ObjectId.GenerateNewId(); cmt.Date = DateTime.Now; _property.Update(Query.EQ("_id", Id), Update.PushWrapped("Commnt", cmt).Inc("TotalComments", 1)); return cmt; }
public ActionResult AddComment(string Id, Comment cmt) { if (ModelState.IsValid) { var newComment = new Comment() { commentID = cmt.commentID, Name = cmt.Name, Cmmnt = cmt.Cmmnt, Date = cmt.Date }; _property.AddCmmnt(Id, cmt); ViewBag.PostId = Id; return Json( new { Result="ok", CommentHtml=RenderPartialViewToString("Comment",newComment), FormHtml=RenderPartialViewToString("AddComment", new Comment()) }); } ViewBag.PostId = Id; return Json( new { Result = "fail", FormHtml = RenderPartialViewToString("AddComment", cmt) }); }