Exemple #1
0
        /// <summary>
        /// Populates the tenant configs.
        /// </summary>
        /// <param name="tenant">The tenant.</param>
        /// <param name="host">The full address.</param>
        /// <param name="databaseConfig">The database configuration.</param>
        /// <param name="tenantConfig">The tenant configuration.</param>
        /// <returns></returns>
        public TenantConfig PopulateTenantConfigs(string tenant, string host, DatabaseConfig databaseConfig, TenantConfig tenantConfig)
        {
            //get user from url
            string user;

            if (host.Contains("localhost"))
            {
                user = "******";
            }
            else
            {
                string[] hostpieces = host.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
                user = hostpieces[2];
            }

            var connectionString = GetBasicSqlConnectionString(databaseConfig);

            var tenantDetails = _tenantsRepository.GetTenant(tenant);

            if (tenantDetails != null)
            {
                //get the venue details and populate in config settings
                var venueDetails     = _venuesRepository.GetVenueDetails(connectionString, tenantDetails.TenantId);
                var venueTypeDetails = _venueTypesRepository.GetVenueType(venueDetails.VenueType, connectionString,
                                                                          tenantDetails.TenantId);
                var countries = _countryRepository.GetAllCountries(connectionString, tenantDetails.TenantId);

                //get country language from db
                var        country      = _countryRepository.GetCountry(venueDetails.CountryCode, connectionString, tenantDetails.TenantId);
                RegionInfo regionalInfo = new RegionInfo(country.Language);

                return(new TenantConfig
                {
                    VenueName = venueDetails.VenueName,
                    BlobImagePath = tenantConfig.BlobPath + venueTypeDetails.VenueType + "-user.jpg",
                    EventTypeNamePlural = venueTypeDetails.EventTypeShortNamePlural.ToUpper(),
                    TenantId = tenantDetails.TenantId,
                    TenantName = venueDetails.DatabaseName,
                    BlobPath = tenantConfig.BlobPath,
                    Currency = regionalInfo.CurrencySymbol,
                    TenantCulture =
                        (!string.IsNullOrEmpty(venueTypeDetails.Language)
                            ? venueTypeDetails.Language
                            : tenantConfig.TenantCulture),
                    TenantCountries = countries,
                    TenantIdInString = tenantDetails.TenantIdInString,
                    User = user
                });
            }
            return(null);
        }
        public void GetTenant()
        {
            var result = _tenantsRepository.GetTenant("tenantName");

            Assert.IsNotNull(result);
        }