public JsonResult DeleteAnEmployee(int employeeId) { try { return(new JsonResult(_employeeService.DeleteAnEmployee(employeeId))); } catch (Exception ex) { return(new JsonResult(ResponseValidation.GetHTTPStatusCode(ex))); } }
public JsonResult GetAllEmployee() { try { return(new JsonResult(_employeeService.GetAllEmployees())); } catch (Exception ex) { return(new JsonResult(ResponseValidation.GetHTTPStatusCode(ex))); } }
public JsonResult CreateNewtEmployee([FromBody] EmployeeToAdd employeeToAdd) { try { var newEmployee = new Employee() { EmployeeAddress = employeeToAdd.Address, EmployeeAge = employeeToAdd.Age, EmployeeName = employeeToAdd.Name, EmployeeSalary = employeeToAdd.Salary }; return(new JsonResult(_employeeService.CreateNewEmployee(newEmployee))); } catch (Exception ex) { return(new JsonResult(ResponseValidation.GetHTTPStatusCode(ex))); } }
public JsonResult UpdateAnExistingEmployee(int employeeId, [FromBody] EmployeeToUpdate employeeToUpdate) { try { var modifiedEmployee = new Employee { EmployeeAddress = employeeToUpdate.Address, EmployeeAge = employeeToUpdate.Age, EmployeeName = employeeToUpdate.Name, EmployeeSalary = employeeToUpdate.Salary, EmployeeStatus = employeeToUpdate.Status }; return(new JsonResult(_employeeService.UpdateAnExistingEmployee(employeeId, modifiedEmployee))); } catch (Exception ex) { return(new JsonResult(ResponseValidation.GetHTTPStatusCode(ex))); } }