public async Task OnGetAsync() { Input = new TenantInfoModel(); if (CurrentTenant.IsAvailable) { var tenant = await TenantStore.FindAsync(CurrentTenant.GetId()); Input.Name = tenant?.Name; } }
public async Task OnGetAsync(Guid id) { var defaultConnectionString = await _tenantAppService.GetDefaultConnectionStringAsync(id); Tenant = new TenantInfoModel { Id = id, DefaultConnectionString = defaultConnectionString, UseSharedDatabase = defaultConnectionString.IsNullOrWhiteSpace() }; }
public virtual async Task <IActionResult> OnGetAsync() { var editionLookup = await EditionAppService.GetEditionLookupAsync(); Editions = editionLookup.Items .Select(x => new SelectListItem(x.DisplayName, x.Id.ToString())) .ToList(); Tenant = new TenantInfoModel(); return(await Task.FromResult <IActionResult>(Page())); }
public virtual async Task <IActionResult> OnGetAsync(Guid id) { var defaultConnectionString = await TenantAppService.GetDefaultConnectionStringAsync(id); Tenant = new TenantInfoModel { Id = id, DefaultConnectionString = defaultConnectionString, UseSharedDatabase = defaultConnectionString.IsNullOrWhiteSpace() }; return(Page()); }
/// <summary> /// This extension method is used to build a connection string from the specified tenant model object. /// </summary> /// <param name="tenant">Contains the tenant model object to retrieve connection string values from.</param> /// <param name="securityKey">Contains the security key used to decrypt protected tenant information.</param> /// <returns>Returns a connection string for the specified tenant object.</returns> public static string BuildConnectionString(this TenantInfoModel tenant, string securityKey = "") { if (tenant == null) { throw new ArgumentNullException(nameof(tenant)); } return(ConnectionFactory.BuildConnectionString( tenant.DbmsType, tenant.DatabaseSource, tenant.DatabaseName, tenant.DatabaseUserId, tenant.DatabasePassword.Decrypt(securityKey), tenant.ExtendedConnectionString)); }
public async Task <IActionResult> PutAsync([FromBody] TenantInfoModel command) { var idTenant = await _workContext.GetTenantCodeAsync(); var repoTenant = _uow.GetRepository <ITenantRepository>(); var info = await repoTenant.GetInfoByCodeAsync(idTenant); info.City = command.City; info.District = command.District; info.LegalName = command.LegalName; info.Fax = command.Fax; info.Emails = command.Emails; info.BusinessType = command.BusinessType; if (command.Metadata != null && command.Metadata.Count != 0) { info.Metadata = JsonConvert.SerializeObject(command.Metadata); } repoTenant.UpdateInfo(info); await _uow.CommitAsync(); return(Ok()); }
public async Task OnGetAsync(Guid id) { TenantInfo = ObjectMapper.Map <TenantDto, TenantInfoModel>( await _tenantAppService.GetAsync(id) ); }
public async Task OnGetAsync(Guid id) { Tenant = ObjectMapper.Map <TenantDto, TenantInfoModel>( await _tenantAppService.GetAsync(id) .ConfigureAwait(false)); }
public virtual Task <IActionResult> OnGetAsync() { Tenant = new TenantInfoModel(); return(Task.FromResult <IActionResult>(Page())); }
public async Task <IActionResult> GetAsync() { var tenantCode = await _workContext.GetTenantCodeAsync(); var repoTenant = _uow.GetRepository <ITenantRepository>(); var info = await repoTenant.GetInfoByCodeAsync(tenantCode); if (info == null) { return(NotFound()); } var model = new TenantInfoModel { Id = info.Id, Code = info.Code, FullNameVi = info.FullNameVi, TaxCode = info.TaxCode, Address = info.Address, City = info.City, District = info.District, Country = info.Country, Emails = info.Emails, Fax = info.Fax, FullNameEn = info.FullNameEn, LegalName = info.LegalName, BusinessType = info.BusinessType, }; //Nếu setting ko có metadata thì trả về kết quả luôn var repoSetting = _uow.GetRepository <ISettingRepository>(); var setting = await repoSetting.GetByKeyAsync(Guid.Empty, SettingKey.ThongTinDoanhNghiep_Khac.ToString()); if (setting == null) { return(Ok(model)); } //Metadata lấy được từ DB var metadatas = string.IsNullOrWhiteSpace(info.Metadata) ? new List <MetadataModel>() : JsonConvert.DeserializeObject <List <MetadataModel> >(info.Metadata); model.Metadata = new List <MetadataModel>(); var splited1 = setting.Value.Split("|"); foreach (var item in splited1) { var splited2 = item.Split(":"); var key = splited2[0]; var name = splited2[1]; var metadata = metadatas.FirstOrDefault(x => x.Key == key); //Nếu DB ko lưu value thì trả về null model.Metadata.Add(new MetadataModel { Key = key, Name = name, Value = metadata == null ? null : metadata.Value }); } return(Ok(model)); }