public async Task <Tenant> CreateAsync(TenantCreator tenant) { var tenantId = tenant.Id ?? throw new ArgumentException("Tenant id is mandatory"); if (await _tenantRepository.ExistsByIdAsync(tenantId)) { throw new IllegalArgumentException(code: "TENANT_EXISTS", message: $"Tenant {tenantId} already exists"); } return(await _tenantRepository.InsertAsync(tenant.ToTenant())); }
public async Task <Tenant> CreateAsync(Tenant tenant) { var tenantId = tenant.Id ?? throw new ArgumentException(_sl[TenantResource.TENANT_ID_IS_MANDATORY]); if (await _tenantRepository.ExistsByIdAsync(tenantId)) { throw new IllegalArgumentException(code: "TENANT_EXISTS", message: string.Format(_sl[TenantResource.TENANT_P0_ALREADY_EXISTS] !, tenantId)); } var tenantRow = await _tenantRepository.InsertAsync(_mapper.Map <TenantRow>(tenant)); return(_mapper.Map <Tenant>(tenantRow)); }