Esempio n. 1
0
        public ActionResult Index()
        {
            //var _jobLogic = ObjectFactory.GetInstance<Jobs>();
            //_jobLogic.MorningMessage(null, 1);

            var model = new Homepage();

            model.RestaurantsForToday = _restaurantOptionLogic.GetAndSaveOptions().ToList();
            model.YourVote = _voteLogic.GetItem(CurrentUser.Id, Core.Helpers.AdjustTimeOffsetFromUtc(DateTime.UtcNow));
            model.PeopleWhoVotedToday = _userLogic.GetListByVotedDate(null, null).ToList();
            model.WinningRestaurant = _restaurantOptionLogic.TodaysSelection();
            if (model.YourVote != null)
            {
                model.YourVote.Restaurant = _restaurantLogic.Get(model.YourVote.RestaurantId);
                if(model.WinningRestaurant !=null)
                    model.YourRating = _restaurantRatingLogic.GetAllByUser(CurrentUser.Id).FirstOrDefault(f => f.RestaurantId == model.WinningRestaurant.RestaurantId);
            }

            var currenttime = Lunch.Core.Helpers.AdjustTimeOffsetFromUtc(DateTime.UtcNow);

            return RedirectCheck(model, currenttime);
        }
Esempio n. 2
0
        private ActionResult RedirectCheck(Homepage model, DateTime currenttime)
        {
            if (!Helpers.IsLunchDate(Core.Helpers.AdjustTimeOffsetFromUtc(DateTime.UtcNow)))
            {
                return View("nottoday", model);
            }
            if (currenttime < new DateTime(currenttime.Year, currenttime.Month, currenttime.Day, 7, 30, 0))
            {
                return View("notyet", model);
            }

            if (currenttime > new DateTime(currenttime.Year, currenttime.Month, currenttime.Day, 7, 30, 0) && currenttime < new DateTime(currenttime.Year, currenttime.Month, currenttime.Day, 10, 30, 0))
            {
                return View(model.YourVote == null ? "vote" : "voted", model);
            }

            if (currenttime > new DateTime(currenttime.Year, currenttime.Month, currenttime.Day, 10, 30, 0) && currenttime < new DateTime(currenttime.Year, currenttime.Month, currenttime.Day, 11, 15, 0))
            {
                //if you vetoed today just show where we are now going
                var todayveto = _vetoLogic.GetUsedTodayForUser(CurrentUser.Id);
                if (todayveto != null)
                {
                    ViewBag.YouVetoed = true;
                    return View("going", model);
                }

                // If you have overrides you can override otherwise show results.
                var unusedvetos = _vetoLogic.GetAllActiveForUser(CurrentUser.Id);
                if (unusedvetos.Any() && model.YourVote != null )
                    return View("youcanveto", model);

                return View(model.YourVote == null ? "comebacktomorrow" : "voted", model);

            }

            if (currenttime > new DateTime(currenttime.Year, currenttime.Month, currenttime.Day, 11, 15, 0) && currenttime < new DateTime(currenttime.Year, currenttime.Month, currenttime.Day, 14, 0, 0))
            {
                return View("going", model);
            }

            if (currenttime > new DateTime(currenttime.Year, currenttime.Month, currenttime.Day, 14, 0, 0))
            {
                return View(model.YourVote == null ? "comebacktomorrow" : "Rate", model);
            }
            return null;
        }