예제 #1
0
        public async Task <IActionResult> Post([FromBody] EmployeeDto employeeDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var createdEmployeeID = await _employeesService.CreateEmployeeAsync(employeeDto);

            employeeDto.ID = createdEmployeeID;

            var routevalues             = new { controller = "Employees", id = createdEmployeeID };
            CreatedAtRouteResult result = CreatedAtRoute("GetEmployee", routevalues, employeeDto);

            return(result);
        }