public async Task <ActionResult <EmployeeTaskDto> > CreateNewTaskForEmployee(Guid employeeId, [FromBody] EmployeeTaskAddDto employeeTask) { //EmployeeExistAsync返回类型是task<bool>,这里是异步的,所以要await if (!await _employeeRepository.EmployeeExistAsync(employeeId)) { return(NotFound()); } var entity = _mapper.Map <EmployeeTask>(employeeTask); _employeeTaskRepository.AddTask(employeeId, entity); await _employeeTaskRepository.SaveAsync(); var employeeTaskDto = _mapper.Map <EmployeeTaskDto>(entity); return(CreatedAtRoute(nameof(GetTaskByTaskId), routeValues: new { //employeeId = employeeId, taskId = employeeTaskDto.taskId }, value: employeeTaskDto)); }