Ejemplo n.º 1
0
 public ActionResult Index(string commentText)
 {
     Comment newComment = new Comment();
     newComment.email = Session["email"].ToString();
     newComment.comment = commentText;
     CommentsModel.InsertComment(newComment);
     return RedirectToAction("Index", "Comments");
 }
Ejemplo n.º 2
0
        public static void InsertComment(Comment comment)
        {
            MongoDatabase db = DBConnection.Db();
            if (!db.CollectionExists("comments"))
                db.CreateCollection("comments");
            var comments = db.GetCollection("comments");

            var commentObject = new BsonDocument();
            commentObject["email"] = comment.email;
            commentObject["comment"] = comment.comment;
            commentObject["dateTime"] = DateTime.Now;
            comments.Insert(commentObject);
        }