コード例 #1
0
 public ActionResult CreateEmployee(Employee objEmp)
 {
     try {
         da = new DataAccess();
         da.CreateEmployee(objEmp);
         return Json(new { IsDataInserted = true }, JsonRequestBehavior.AllowGet);
     }
     catch (Exception ex) {
         return Json(new { IsDataInserted = false, Message = ex.Message }, JsonRequestBehavior.AllowGet);
     }
 }
コード例 #2
0
ファイル: DataAccess.cs プロジェクト: SangSuantak/MongoApp
        public void CreateEmployee(Employee objEmp)
        {
            MongoCollection<BsonDocument> employees = mDatabase.GetCollection<BsonDocument>("Employees");

            BsonDocument employee = new BsonDocument {
                { "FirstName", objEmp.FirstName },
                { "LastName", objEmp.LastName },
                { "Address", objEmp.Address },
                { "City", objEmp.City },
                { "DepartmentId", objEmp.DepartmentId }
            };

            employees.Insert(employee);
        }