コード例 #1
0
 public ActionResult Create(NewsCategoryModel model)
 {
     var categories = mongo.GetDatabase("ddd").GetCollection<NewsCategoryModel>("newscategories");
     try
     {
         categories.Insert(model);
         return RedirectToAction("Index");
     }
     catch
     {
         throw;
     }
 }
コード例 #2
0
        public ActionResult Edit(string id, NewsCategoryModel model)
        {
            var categories = mongo.GetDatabase("ddd").GetCollection<NewsCategoryModel>("newscategories");
            try
            {
                var category = categories.FindOneById(new ObjectId(id));
                TryUpdateModel(category);
                categories.Save(category);
                return RedirectToAction("Index");
            }
            catch
            {

                throw;
            }
        }