Esempio n. 1
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. 2
0
        public ActionResult Update(string hash)
        {
            var id = ToolService.GetIdBHash(hash);

            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            var objNewsletter = Newsletter.Load(id.Value);

            if (objNewsletter == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            var goback = false;

            if (!objNewsletter.Ativo)
            {
                goback = true;
                objNewsletter.Ativo    = true;
                objNewsletter.MotivoId = null;
                objNewsletter.Save();
            }

            var model = new NewsletterUpdateViewModel
            {
                //Base
                Title       = "Atualizar preferências de e-mail - Massa News",
                Description = "Atualize suas preferências e receba e-mails personalizados para você.",
                Robots      = "noindex, nofollow",
                Canonical   = $"{Constants.UrlWeb}/newsletter/atualizar",
                //Model
                UserHash         = hash,
                GoBack           = goback,
                PreferenceGroups = PreferenceGroup.GetAll(),
                UserNewsletter   = objNewsletter
            };

            ViewBag.ActiveNav  = "Preferências de e-mail";
            ViewBag.CityLetter = new SelectList(Cidade.GetAllToDictionary(), "Key", "Value", objNewsletter.CidadeId);

            return(View(model));
        }