Esempio n. 1
0
        public ActionResult LoadSectionModule(int locationId, int sectionId)
        {
            //Get the city
            var city = Cidade.Load(locationId);

            var home = city.Microregion.Home;

            //Get list of news highlights
            var lstHighlights = Noticia.GetHighlightNewsByHome(home.Status ? home.Id : 1).ToList();

            //Create initial negation list with hiloghts id's
            var notInList = lstHighlights.Select(s => s.Id).ToList();

            //Get the section
            var section = Section.All().Where(s => s.Id == sectionId).Single();

            if (sectionId == Section.Videos.Id)
            {
                return(PartialView("_DestaqueVideos", GetVideoHighlights(city, ref notInList)));
            }

            //Get the other modules
            var model = GetDestaquesComtags(section, home, ref notInList);

            model.isLazy = false;

            return(PartialView("_DestaqueComTags", model));
        }
Esempio n. 2
0
        private HomeIndex GetHomeIndexModel(int locationId)
        {
            var cacheSrv = new RedisCacheService();

            //Get the city
            var city = Cidade.Load(locationId);

            //Get the home object
            var objHome = city.Microregion.Home;

            #region GET CACHE

            //Set the const time value
            const int time = 1;

            //Set the cache key
            var key = $"Home:{objHome.Id}";

            //Find in the cache for the model
            var objModel = cacheSrv.Get <HomeIndex>(key);

            //If model exists in cache return the object
            if (objModel != null)
            {
                return(objModel);
            }
            #endregion

            //Save the current home state
            var currentHome = objHome;

            //If Home is disabled load the main home
            if (!objHome.Status)
            {
                objHome = Home.Load(1); //Home Curitiba
            }
            //Get list of news highlights
            var lstHighlights = Noticia.GetHighlightNewsByHome(objHome.Id).ToList();

            //Create initial negation list with hiloghts id's
            var notInList = lstHighlights.Select(s => s.Id).ToList();

            objModel = new HomeIndex
            {
                //Base
                Title       = "Massa News - A notícia em movimento!",
                Description = "O Massa News oferece a melhor cobertura jornalística do Paraná com notícias personalizadas da sua região.",
                Robots      = "index, follow",
                Canonical   = Constants.UrlWeb,

                //Model
                Cidade           = Cidade.Load(12), //Curitiba //objCidade,
                SidebarHighlight = objHome.SidebarHighlight,
                TemplateId       = objHome.Highlight.TemplateId,
                Highlights       = lstHighlights
            };

            //SUA REGIÃO
            //Este módulo recebe a cidade original
            objModel.DestaqueComTagsSuaRegiao = GetDestaquesComtags(Section.SuaRegiao, currentHome, ref notInList);

            //ESPORTES
            objModel.DestaqueComTagsEsportes = GetDestaquesComtags(Section.Esportes, currentHome, ref notInList);

            //ENTRETEDIMENTO
            objModel.DestaqueComTagsEntretedimento = GetDestaquesComtags(Section.Entretenimento, currentHome, ref notInList);

            //PARANÁ - TODOS OS PLANTÕES
            objModel.DestaqueComTagsParana = GetDestaquesComtags(Section.Parana, currentHome, ref notInList);

            //CATEGORIAS DESTAQUES
            objModel.CategoriasDestaquesModel = GetCategoriaDestaquesModel(objHome.Id, ref notInList);

            //VIAJAR É MASSA
            objModel.DestaqueComTagsViajarEMassa = GetDestaquesComtags(Section.ViajarEMassa, currentHome, ref notInList);

            //WHERE CURITIBA
            if (currentHome.Id == 1)
            {
                objModel.DestaqueComTagsWhereCuritiba = GetDestaquesComtags(Section.WhereCuritiba, currentHome, ref notInList);
            }

            //NEGÓCIOS DA TERRA
            objModel.DestaqueComTagsNegociosDaTerra = GetDestaquesComtags(Section.NegociosDaTerra, currentHome, ref notInList);

            //VIDEOS
            objModel.DestaqueVideo = GetVideoHighlights(city, ref notInList);

            //FOTOS (GALERIAS)
            objModel.HighlightsFotos = Noticia.GetBySection(8, Section.Fotos, 1, ref notInList, true).ToList();

            //BLOGS
            objModel.Blogs = GetBlogListByMicroregion(currentHome.MicroregiaoId);

            #region ENQUETE
            var statusEnquete = EnqueteSrv.GetStatusEnquete();

            switch (statusEnquete.Status)
            {
            case (int)EnqueteEnum.Estadual:
                objModel.ShowEnquete = true;
                objModel.EnqueteId   = Constants.EnqueteRegionalId;
                break;

            case (int)EnqueteEnum.Regional:
                foreach (var item in statusEnquete.RegioesEnquetes.Where(item => objHome.MicroregiaoId == item.MicroregiaoId && item.Status))
                {
                    objModel.ShowEnquete = true;
                    objModel.EnqueteId   = item.EnqueteId;
                }
                break;

            default:
                objModel.ShowEnquete = false;
                break;
            }
            #endregion

            //Set the cache
            cacheSrv.Set(key, objModel, time);

            return(objModel);
        }