public void CreateDepartment(Department objDept) { MongoCollection<BsonDocument> departments = mDatabase.GetCollection<BsonDocument>("Departments"); BsonDocument department = new BsonDocument { { "DepartmentName", objDept.DepartmentName }, { "HeadOfDepartmentId", objDept.HeadOfDepartmentId } }; departments.Insert(department); }
public ActionResult CreateDepartment(Department objDept) { try { da = new DataAccess(); da.CreateDepartment(objDept); return Json(new { IsDataInserted = true }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { return Json(new { IsDataInserted = false, Message = ex.Message }, JsonRequestBehavior.AllowGet); } }