Ejemplo n.º 1
0
        public ActionResult RegisterVote(int id, VoteModel sessionVoteModel = null)
        {
            var cookie = controllerInformationProvider.GetVotingCookie();

            var vote = new RegisterVoteCommand
            {
                SessionId    = id,
                CookieId     = cookie.Id,
                TimeRecorded = controllerInformationProvider.UtcNow,
                IPAddress    = controllerInformationProvider.GetIPAddress(),
                UserAgent    = controllerInformationProvider.UserAgent,
                Referrer     = controllerInformationProvider.Referrer,
                WebSessionId = controllerInformationProvider.SessionId
            };

            if (controllerInformationProvider.IsLoggedIn())
            {
                vote.UserId = controllerInformationProvider.GetCurrentUser().UserId;
            }

            if (sessionVoteModel != null)
            {
                if (sessionVoteModel.Width != 0 || sessionVoteModel.Height != 0)
                {
                    vote.ScreenResolution = string.Format("{0}x{1}", sessionVoteModel.Width, sessionVoteModel.Height);
                }

                vote.PositionInList = sessionVoteModel.PositionInList;
            }

            messageBus.Send(vote);
            controllerInformationProvider.SaveVotingCookie(cookie);
            return(RedirectOrReturnPartialView(id));
        }
 protected override void SetExpectations(IControllerInformationProvider controllerInformationProvider)
 {
     controllerInformationProvider.IsLoggedIn().Returns(true);
     controllerInformationProvider.GetCurrentUser().Returns(userProfile);
 }
Ejemplo n.º 3
0
 protected override void SetExpectations(IControllerInformationProvider controllerInformationProvider)
 {
     controllerInformationProvider.IsLoggedIn().Returns(false);
     controllerInformationProvider.GetCurrentUser().Returns((UserProfile)null);
 }