Example #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);
        }
        /// <summary>
        /// This method is hit when not passing any tenant name
        /// Will display the Events Hub page
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            var tenantsModel = _tenantsRepository.GetAllTenants();

            //get the venue name for each tenant
            foreach (var tenant in tenantsModel)
            {
                VenueModel venue = _venuesRepository.GetVenueDetails(_connectionString, tenant.TenantId);
                tenant.VenueName  = venue.VenueName;
                tenant.TenantName = venue.DatabaseName;
            }

            return(View(tenantsModel));
        }