public ActionResult Create(MyTask task) { try { dal.CreateTask(task); return RedirectToAction("Index"); } catch { return View(); } }
// Creates a Task and inserts it into the collection in MongoDB. public void CreateTask(MyTask task) { var collection = GetTasksCollectionForEdit(); try { collection.InsertOne(task); } catch (MongoCommandException ex) { string msg = ex.Message; } }