コード例 #1
0
        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()));
        }
コード例 #2
0
        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));
        }