public void TestAddQuestion() { using (var s = new MongoSession()) { Question q = new Question(); q.Content = "ContentTest123"; q.Ask = "Ask"; q.Number = 100; q.Rate = 3; q.Source = "GWD"; s.Add(q); } using (var s = new MongoSession()) { var q2 = s.Query<Question>().FirstOrDefault(q=> q.Number==100); Assert.IsNotNull(q2); Assert.AreEqual(q2.Content, "ContentTest123"); } using (var s = new MongoSession()) { s.GetCollection<Question>().Delete(new { Number = 100 }); } using (var s = new MongoSession()) { var q2 = s.Query<Question>().FirstOrDefault(q => q.Number == 100); Assert.IsNull(q2); } }
public ActionResult Salvar(Usuario usuario) { using (var session = new MongoSession()) { session.Add(usuario); } return(View(usuario)); }
public ActionResult Salvar(Preco preco) { using (var session = new MongoSession()) { session.Add(preco); } return(View(preco)); }
public ActionResult Salvar(Filial filial) { using (var session = new MongoSession()) { session.Add(filial); } return(View(filial)); }
public ActionResult Create(Question q) { try { // TODO: Add insert logic here using (var s = new MongoSession()) { q.Number = new IDProvider().GetNewID("Question"); q.Info = new EntityInfo() { CrTime = DateTime.Now, CrUser = "******", LastModified = DateTime.Now }; s.Add(q); } return RedirectToAction("Index"); } catch { return View(); } }