Пример #1
0
        public IHttpActionResult Put(
            [FromUri] int id,
            [FromBody] CreateTenantModel command)
        {
            if (command == null || !ModelState.IsValid)
            {
                return(this.Error().InvalidParameters("Tenant body parameters missing"));
            }
            if (command.TenantDbProvider == null || command.TenantDbConfiguration == null)
            {
                return(this.Error().InvalidParameters("Tenant Db information missing"));
            }

            var tenant = _tenantsRepository.GetById(id);

            tenant.Change(command.Name,
                          command.DefaultTheme,
                          DatabaseProviderConfiguration.Create(command.TenantDbProvider, command.TenantDbConfiguration));
            _tenantsRepository.Update(tenant);
            _tenantsRepository.SaveChanges();
            var tenantModel = _mapper.Map <TenantModel>(tenant);

            return(Ok(tenantModel));
        }
Пример #2
0
 private DatabaseProviderConfiguration CreateDBProviderConfiguration(CreateTenantModel command)
 => String.IsNullOrEmpty(command.TenantDbConnectionString)
             ? DatabaseProviderConfiguration.CreateFromConfiguration(command.TenantDbProvider, command.TenantDbConfiguration)
             : DatabaseProviderConfiguration.Create(command.TenantDbProvider, command.TenantDbConnectionString);