public async Task CreateAndSendInvitationAsync(Employee employee, ServerSettings server, DateTime validTo) { if (employee == null) { throw new ArgumentNullException(nameof(employee)); } if (employee.Id == null) { throw new ArgumentNullException(nameof(employee.Id)); } if (employee.Email == null) { throw new ArgumentNullException(nameof(employee.Email)); } var activationCode = GenerateActivationCode(); var invitation = new SoftwareVaultInvitation() { EmployeeId = employee.Id, Status = SoftwareVaultInvitationStatus.Pending, CreatedAt = DateTime.UtcNow, ValidTo = validTo.Date, AcceptedAt = null, SoftwareVaultId = null, ActivationCode = activationCode }; var created = await _softwareVaultInvitationRepository.AddAsync(invitation); var activation = new SoftwareVaultActivation() { ServerAddress = server.Url, ActivationId = created.Id, ActivationCode = activationCode }; await _emailSenderService.SendSoftwareVaultInvitationAsync(employee, activation, validTo); }