public ActionResult Create(Post post) { var query = Query.EQ("UUID", post.UUID); var update = Update.Set("Title", post.Title) .Set("Content", post.Content); if (post.TimeCreated == DateTime.MinValue) { post.TimeCreated = DateTime.Now; post.UUID = System.Guid.NewGuid().ToString(); //_collection.Insert(post); _collectionPost.Save(post); } else { _collectionPost.Update(query, update); } return RedirectToAction("Index", "Home", new { page = post.Page }); }
public ActionResult Create(Post post) { _collectionPost.Insert(post); return RedirectToAction("Index"); }
public ActionResult Index(string page, bool update, string id) { Post post = null; if (update) { post = _collectionPost.FindOneById(ObjectId.Parse(id)); } else { post = new Post() { Page = page, TimeCreated = DateTime.MinValue, }; } return View(post); }