public ActionResult Index()
        {
            var cinemas = db.sp_GetAvailableMovies().
                          Where(item => item.BeginDatetime.IsInSameWeek(DateTime.Now)).ToList();
            List <AvailableMovieViewModel> cinemasAvailable = ConvertMoviesToViewModels(cinemas);

            if (HttpContext.KeyExistsOnCache(cinemasAvailableKey))
            {
                HttpContext.RemoveValuesFromCache(cinemasAvailableKey);
            }

            HttpContext.AddValuesToCache(cinemasAvailableKey, cinemasAvailable);

            if (TempData["MessageValidation"] != null)
            {
                ViewBag.MessageValidation = (string)TempData["MessageValidation"];
            }

            CinemaAvailableViewModel moviesAvailable = new CinemaAvailableViewModel()
            {
                AvailableMovies = cinemasAvailable,
                Recomendations  = GetRecomendations()
            };

            return(View(moviesAvailable));
        }
 private void LoadDirectionsParameter()
 {
     if (!HttpContext.KeyExistsOnCache(cacheDirectionKey))
     {
         var parameter = db.Parameter.Find(directionParameter);
         if (parameter != null)
         {
             string          paramValue = parameter.ParamValue;
             List <Province> provinces  = JsonConvert.DeserializeObject <List <Province> >(paramValue);
             HttpContext.AddValuesToCache(cacheDirectionKey, provinces);
         }
     }
 }
        public ActionResult Create(CinemaServiceStep1 cinemaServiceStep1)
        {
            if (ModelState.IsValid)
            {
                if (HttpContext.KeyExistsOnCache("cinemaTemp"))
                {
                    HttpContext.RemoveValuesFromCache("cinemaTemp");
                }

                HttpContext.AddValuesToCache("cinemaTemp", cinemaServiceStep1);

                var cinemasAvailable = (List <AvailableMovieViewModel>)HttpContext.GetValuesFromCache(cinemasAvailableKey);
                var movieAvailable   = cinemasAvailable.
                                       FirstOrDefault(item => item.Schedules.Select(sch => sch.CinemaScheduleId).ToList()
                                                      .Contains(cinemaServiceStep1.CinemaScheduleId));

                var scheduleSelected = movieAvailable.Schedules.
                                       FirstOrDefault(item => item.CinemaScheduleId == cinemaServiceStep1.CinemaScheduleId);

                return(View("CreateStep2", null));
            }

            return(View(cinemaServiceStep1));
        }