private ActionResult PlacementView(IPollPlacement placement, bool random, string alias)
        {
            ViewData["alias"] = alias;

            ViewData["random"] = random;

            ViewData[PortalExtensions.PortalViewContextKey] = PortalViewContext();

            return(View("PollPlacement", placement));
        }
        public PollPlacementDrop(IPortalLiquidContext portalLiquidContext, IPollPlacement pollPlacement)
            : base(portalLiquidContext, pollPlacement.Entity)
        {
            if (pollPlacement == null)
            {
                throw new ArgumentNullException("pollPlacement");
            }

            PollPlacement = pollPlacement;

            _polls = new Lazy <PollDrop[]>(() => pollPlacement.Polls.Select(e => new PollDrop(this, e)).ToArray(),
                                           LazyThreadSafetyMode.None);

            _placementUrl = new Lazy <string>(GetPlacementUrl, LazyThreadSafetyMode.None);
            _randomUrl    = new Lazy <string>(GetRandomUrl, LazyThreadSafetyMode.None);
            _submitUrl    = new Lazy <string>(GetSubmitUrl, LazyThreadSafetyMode.None);
        }
        protected IPoll SelectRandomPoll(IPollPlacement placement)
        {
            if (placement == null)
            {
                return(null);
            }

            var array = placement.Polls.ToArray();

            if (array.Length == 0)
            {
                return(null);
            }

            var random = new Random(DateTime.Now.Millisecond);

            return(array[random.Next(0, array.Length)]);
        }