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.GetIPAddress().Returns(LocalIpAddress); }