예제 #1
0
 public JsonResult DeleteAnEmployee(int employeeId)
 {
     try
     {
         return(new JsonResult(_employeeService.DeleteAnEmployee(employeeId)));
     }
     catch (Exception ex)
     {
         return(new JsonResult(ResponseValidation.GetHTTPStatusCode(ex)));
     }
 }
예제 #2
0
 public JsonResult GetAllEmployee()
 {
     try
     {
         return(new JsonResult(_employeeService.GetAllEmployees()));
     }
     catch (Exception ex)
     {
         return(new JsonResult(ResponseValidation.GetHTTPStatusCode(ex)));
     }
 }
예제 #3
0
        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)));
            }
        }
예제 #4
0
        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)));
            }
        }