public async Task <Option <Organization> > AddAsync(Organization o) { // Begin by adding the organization, this serves as a default rollback state o = _orgRepo.Add(o); await _orgRepo.UnitOfWork.Commit(); // Attempt to create all infrastructure at API necessary. If any step fails, // the state will stay as not successfully created, and a separate job will clean it up later var request = new TenantCreationRequest() { TenantId = o.Id.ToString() }; var outcome = await _createTenantClient.CreateAsync(request); if (outcome.Success) { o.SuccessfullyActivated(); await _orgRepo.UnitOfWork.Commit(); return(Option <Organization> .Some(o)); } return(Option <Organization> .None); }
public override async Task <TenantCreationOutcome> Create(TenantCreationRequest request, ServerCallContext ctx) => new TenantCreationOutcome() { Success = await _tenantInfraManager.InitializeTenantAsync(request.TenantId) };