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); } }
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); }