Esempio n. 1
0
        //private void getTemperature(int locationId)
        //{
        //  var objCidade = LocalSrv.GetCidadeByIdCached(locationId);

        //  var obj = WeatherSrv.GetWeather(objCidade.Id);

        //  ViewBag.City = obj == null ? string.Empty : obj.City ?? string.Empty;
        //  ViewBag.Description = obj == null ? string.Empty : obj.Description ?? string.Empty;
        //  ViewBag.Icon = obj == null ? string.Empty : obj.Icon ?? string.Empty;
        //  ViewBag.Temperature = obj == null ? string.Empty : obj.Temperature == 0 ? string.Empty : obj.Temperature.ToString();
        //}

        private DestaqueVideoViewModel GetRegionHighlights(int microregionId)
        {
            var objModel = new DestaqueVideoViewModel
            {
                Url      = "noticias",
                Titulo   = "Notícias",
                Sections = new List <DestaqueVideoViewModel.VideoSection>()
            };

            var lstMicroregions = Microregiao.GetAllByStatus(true);

            foreach (var microregion in lstMicroregions)
            {
                var section = new DestaqueVideoViewModel.VideoSection
                {
                    Url        = microregion.Url,
                    Title      = microregion.Nome,
                    Videos     = NoticiaSrv.GetLastestVideoNewsByMicroregion(4, microregion.Id).Select(VideoModel.Map),
                    ButtonText = "Ver mais",
                    ButtonUrl  = $"/videos/{microregion.Url}",
                    Selected   = microregionId == microregion.Id
                };

                objModel.Sections.Add(section);
            }

            if (objModel.Sections.All(s => !s.Selected))
            {
                objModel.Sections.First().Selected = true;
            }

            return(objModel);
        }
Esempio n. 2
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var request = filterContext.HttpContext.Request;

            //Recupera o id da cidade que está gravada no cookie
            var cidadeId = CookieFx.GetLocationId(request);

            //Get current city object
            var currentCity = Cidade.Load(cidadeId);

            //Set the whether
            GetTemperature(filterContext, cidadeId);

            //Current city
            if (filterContext.Controller.ViewBag.CurrentCity == null)
            {
                filterContext.Controller.ViewBag.CurrentCity = currentCity;
            }

            //Microregions
            if (filterContext.Controller.ViewBag.Microregions == null)
            {
                filterContext.Controller.ViewBag.Microregions = Microregiao.GetAllUrlToDictionary();
            }

            //Cities
            if (filterContext.Controller.ViewBag.Cidades == null)
            {
                filterContext.Controller.ViewBag.Cidades = new SelectList(Cidade.GetAllToDictionary(), "Key", "Value", cidadeId);
            }
        }
Esempio n. 3
0
        private List <Blog> GetBlogListByMicroregion(int microregionId)
        {
            //Get the microregion
            var microregion = Microregiao.Load(microregionId);

            //Get the home
            var home = microregion.Home;

            //Get secondary hilight by section
            var sh = home.GetSecondaryHighlight(Section.Blogs.Id);

            //Get the list of blog in the microregion
            //var lstBlogs = Blog.GetByMicroregion(home.MicroregiaoId).Where(b => b.Id != sh.BlogId1 && b.Id != sh.BlogId2 && b.Id != sh.BlogId3).Take(5).ToList();
            var lstBlogs = Blog.GetByMicroregion(home.MicroregiaoId).Where(b => b.Id != sh.BlogId1 && b.Id != sh.BlogId2).Take(5).ToList();

            if (sh.Status)
            {
                lstBlogs.Insert(0, Blog.LoadWithLastNews(sh.BlogId1.Value));
                lstBlogs.Insert(1, Blog.LoadWithLastNews(sh.BlogId2.Value));
                //lstBlogs.Insert(2, Blog.LoadWithLastNews(sh.BlogId3.Value));
            }

            foreach (var objBlog in lstBlogs)
            {
                if (string.IsNullOrEmpty(objBlog.Img))
                {
                    var objautor = objBlog.Autores.FirstOrDefault();

                    if (objautor != null)
                    {
                        objBlog.Img = $"{Constants.UrlDominioEstaticoUploads}/autores/{objautor.Avatar}";
                    }
                    else
                    {
                        objBlog.Img = Url.Content("~/content/images/placeholders/no-avatar.png");
                    }
                }
                else
                {
                    objBlog.Img = $"{Constants.UrlDominioEstaticoUploads}/{"blog"}/{objBlog.Img}";
                }
            }

            return(lstBlogs.Take(5).ToList());
        }