Esempio n. 1
0
        public FeelSiteContentQueryResult Handle(FeelSiteContentQuery query)
        {
            var siteContentResult = _eventSiteContentMappingRepository.GetBySiteId(query.SiteId);
            var siteContent       = Mapper.Map <FIL.Contracts.Models.FeelSiteContent>(siteContentResult);

            return(new FeelSiteContentQueryResult
            {
                FeelSiteContent = siteContent,
            });
        }
        public FeelCustomDefaultContentQueryResult Handle(FeelCustomDefaultContentQuery query)
        {
            var siteBannerModel   = _eventBannerMappingRepository.GetBySiteId(query.SiteId);
            var siteBanners       = AutoMapper.Mapper.Map <List <SiteBannerDetail> >(siteBannerModel);
            var siteContentResult = _eventSiteContentMappingRepository.GetBySiteId(query.SiteId);
            var siteContent       = AutoMapper.Mapper.Map <FIL.Contracts.Models.FeelSiteContent>(siteContentResult);
            var venueDetails      = _venueRepository.GetBySiteId((int)query.SiteId);
            List <FIL.Contracts.Models.City>    cityResult    = new List <FIL.Contracts.Models.City>();
            List <FIL.Contracts.Models.State>   stateResult   = new List <FIL.Contracts.Models.State>();
            List <FIL.Contracts.Models.Country> countryResult = new List <FIL.Contracts.Models.Country>();
            var cityIds        = venueDetails.Select(v => v.CityId).Distinct();
            var cityDetails    = _cityRepository.GetByCityIds(cityIds);
            var stateIds       = cityDetails.Select(c => c.StateId).Distinct();
            var stateDetails   = _stateRepository.GetByStateIds(stateIds);
            var countryIds     = stateDetails.Select(c => c.CountryId).Distinct();
            var countryDetails = _countryRepository.GetByCountryIds(countryIds).GroupBy(p => p.CountryName).Select(grp => grp.FirstOrDefault());

            if (siteContent != null)
            {
                if (siteContent.SiteLevel == Contracts.Enums.SiteLevel.Global)
                {
                    cityResult    = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.City> >(cityDetails);
                    stateResult   = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.State> >(stateDetails);
                    countryResult = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.Country> >(countryDetails);
                }
                else if (siteContent.SiteLevel == Contracts.Enums.SiteLevel.Country)
                {
                    cityResult  = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.City> >(cityDetails);
                    stateResult = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.State> >(stateDetails);
                }
                else if (siteContent.SiteLevel == Contracts.Enums.SiteLevel.State)
                {
                    cityResult = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.City> >(cityDetails);
                }
            }

            return(new FeelCustomDefaultContentQueryResult
            {
                SiteBanners = siteBanners,
                FeelSiteContent = siteContent,
                Countries = countryResult,
                States = stateResult,
                Cities = cityResult,
            });
        }