public IActionResult AddEmployee([FromForm] EmployeeModel employee) { try { var result = _empService.AddEmployee(employee); if (result == null) { return(this.NotFound(new ServiceResponse <EmployeeModel> { StatusCode = (int)HttpStatusCode.NotFound, Message = "Internal server error", Data = null })); } return(Ok(new ServiceResponse <EmployeeModel> { StatusCode = (int)HttpStatusCode.OK, Message = "employee added successfully", Data = result })); } catch (Exception) { return(BadRequest(new ServiceResponse <EmployeeModel> { StatusCode = (int)HttpStatusCode.BadRequest, Message = "Page not Found", Data = null })); } }
public IActionResult GetEmployee(int id) { try { EmployeeModel employee = _empService.GetEmployee(id); if (employee == null) { return(this.NotFound(new ServiceResponse <EmployeeModel> { StatusCode = (int)HttpStatusCode.NotFound, Message = "Internal server error", Data = null })); } return(Ok(new ServiceResponse <EmployeeModel> { StatusCode = (int)HttpStatusCode.OK, Message = "successful", Data = employee })); } catch (Exception) { return(BadRequest(new ServiceResponse <EmployeeModel> { StatusCode = (int)HttpStatusCode.BadRequest, Message = "Page not Found", Data = null })); } }