public async Task <ActionResult <IEnumerable <EmployeeTaskDto> > > GetAllEmployeesTasks() { var employeesTasks = await _employeeTaskRepository.GetTasksAsync(); var employeeTaskDtos = _mapper.Map <IEnumerable <EmployeeTaskDto> >(employeesTasks); return(Ok(employeeTaskDtos)); }
public async Task <IActionResult> DeleteEmployeeWithTask(Guid employeeId) { var employeeEntity = await _employeeRepository.GetEmployeesAsync(employeeId); if (employeeEntity == null) { return(NotFound()); } //虽然级联删除设置了,但是这里要查询一下employee名下的task,加载到dbcontext里 await _employeeTaskRepository.GetTasksAsync(employeeId); _employeeRepository.DeleteEmployee(employeeEntity); await _employeeRepository.SaveAsync(); return(NoContent()); }