public async Task <ActionResult <TenantDTO> > PostTenant(NewTenantRequest tenantRequest) { try { _logger.LogInformation("Creating a new tenant: {NewTenantName} for {OwnerID}, requested by {User}", tenantRequest.Name, tenantRequest.CreatorEmail, User?.Identity?.Name); TenantDTO tenant = await _tenantService.AddTenantAsync(tenantRequest, User?.GetNameIdentifierId() !); _logger.LogInformation("Created a new tenant {NewTenantName} with URL {NewTenantRoute}, and ID {NewTenantID}", tenant.Name, tenant.Route, tenant.Id); return(CreatedAtAction(nameof(GetTenant), new { tenantId = tenant.Id }, tenant)); } catch (DbUpdateException ex) { return(BadRequest((ex.InnerException ?? ex).Message)); } catch (Exception ex) { _logger.LogWarning(ex, "Problem creating tenant with ID {TenantName}", tenantRequest.Name); throw; } }