public int Insert(Employee emp) { try { // Execute the DAL code var result = _employeeDbContext.Create( new MongoDB_Employee { EmpId = emp.Id, Name = emp.Name, Address = emp.Address, DepartmentId = emp.DepartmentId, Type = emp.Type }); // Some logs _loggerService.WriteLog($"Insert Employee succeeded. ObjectId: {result.Id.ToString()}", LOG.Info); // Return the execution result return(0); } catch (Exception ex) { _loggerService.WriteLog($"Insert Employee failed. Exception: {ex.Message}", LOG.Fatal); return(-1); } }
public IActionResult Create([Bind("ID,Name,LastName,NetWage")] Employee employee) { EmployeeContext context = HttpContext.RequestServices.GetService(typeof(Employees.Models.EmployeeContext)) as EmployeeContext; context.Create(employee); ViewData["search"] = ""; ViewData["page"] = 0; ViewData["prevPage"] = -1; ViewData["nextPage"] = 1; return(View("List", context.GetAllEmployees())); }