public async Task <Guid> AddEmployee(EmployeeDto employee) { if (await _employeeContext.CpfExists(employee.Cpf)) { throw new Exception("Employee already exists."); } var mappedEmployee = MapEmployee(employee); var validationResult = await _employeeValidator.ValidateAsync(mappedEmployee, CancellationToken.None); if (validationResult.IsValid) { var result = await _employeeContext.InsertEmployee(mappedEmployee); return(result); } throw new Exception("Invalid employee data."); }