Пример #1
0
        public ActionResult Index()
        {
            var conference = conferenceLoader.LoadConference();

            if (!conference.CanShowSpeakers())
            {
                return(HttpNotFound());
            }

            var speakers        = new List <SpeakerDisplayModel>();
            var speakerProfiles = userProfileRepository.GetAllUserProfiles();

            var sessionLoader     = sessionLoaderFactory.Create(conference);
            var userProfileFilter = userProfileFilterFactory.Create(conference);
            var speakersWhoHaveSubmittedSessions = userProfileFilter.FilterProfiles(speakerProfiles);

            foreach (var speakerProfile in speakersWhoHaveSubmittedSessions)
            {
                var speakersSessions = sessionLoader.LoadSessions(speakerProfile);
                var speaker          = CreateDisplayModel(speakerProfile, speakersSessions);
                speakers.Add(speaker);
            }

            speakers.Sort(new SpeakerDisplayModelComparer());
            return(View(speakers));
        }
Пример #2
0
        public ActionResult Index()
        {
            var conference = conferenceLoader.LoadConference();

            if (!conference.CanShowSessions())
            {
                return(HttpNotFound());
            }

            var speakersLookup = userProfileRepository.GetAllUserProfiles().ToDictionary(p => p.UserName, p => p);
            var sessions       = sessionRepository.GetAllSessions();

            var allSessions = new List <SessionDisplayModel>();
            var showSpeaker = conference.CanShowSpeakers();

            foreach (var session in sessions)
            {
                var profile      = speakersLookup[session.SpeakerUserName];
                var displayModel = CreateDisplayModel(session, profile, showSpeaker);
                allSessions.Add(displayModel);
            }

            sessionSorter.SortSessions(conference, allSessions);

            return(View(new SessionIndexModel
            {
                Sessions = allSessions,
                IsOpenForSubmission = conference.CanSubmit(),
                IsOpenForVoting = conference.CanVote()
            }));
        }
Пример #3
0
        public ActionResult RenderMenu()
        {
            var conference = conferenceLoader.LoadConference();
            var links      = new List <NavigationMenuLinkViewModel>
            {
                CreateLink("Home", "Home", "Index"),
                CreateLink("Sessions", "Session", "Index", () => conference.CanShowSessions() && !conference.CanPublishAgenda()),
                CreateLink("Speakers", "Speaker", "Index", () => conference.CanShowSpeakers() && !conference.CanPublishAgenda()),
                CreateLink("Agenda", "Home", "Agenda", conference.CanPublishAgenda),
                CreateLink("Register", "Home", "Register", conference.CanRegister),
                CreateLink("New to DDD?", "Home", "About"),
                CreateLink("Code of Conduct", "Home", "CodeOfConduct"),
                CreateLink("Venue", "Home", "Venue"),
                CreateLink("Accommodation", "Home", "Accommodation", conference.CanRegister),
                CreateLink("Sponsors", "Home", "Sponsors"),
                CreateLink("Team", "Home", "Team"),
//                    CreateLink("Environmental Policy", "Home", "Environmental"),
                CreateLink("Contact", "Home", "Contact"),
                CreateLink("Admin", "AdminHome", "Index", () => User.IsInRole("Administrator"), new { area = "Admin" }),
            };

            var model = new NavigationMenuViewModel {
                Links = links
            };

            return(PartialView(model));
        }
Пример #4
0
        public BannerModel Get()
        {
            var conference = conferenceLoader.LoadConference();

            if (conference == null)
            {
                return(new BannerModel());
            }

            DateTimeOffset submissionCloses = DateTimeOffset.Now.AddDays(-1);
            DateTimeOffset votingCloses     = DateTimeOffset.Now.AddDays(-1);

            var allDates   = calendarItemRepository.GetAll().ToDictionary(c => c.EntryType, c => c);
            var submission = allDates[CalendarEntryType.SessionSubmission];

            if (submission != null && submission.EndDate.HasValue)
            {
                submissionCloses = submission.EndDate.Value;
            }

            var voting = allDates[CalendarEntryType.Voting];

            if (voting != null && voting.EndDate.HasValue)
            {
                votingCloses = voting.EndDate.Value;
            }

            return(new BannerModel
            {
                IsOpenForSubmission = conference.CanSubmit(),
                IsOpenForVoting = conference.CanVote(),
                SessionSubmissionCloses = submissionCloses.ToString("R"),
                VotingCloses = votingCloses.ToString("R")
            });
        }
        public override void Handle(RegisterVoteCommand message)
        {
            var conference = conferenceLoader.LoadConference(message.SessionId);

            if (conference == null || !conference.CanVote())
            {
                return;
            }

            if (voteRepository.HasVotedFor(message.SessionId, message.CookieId))
            {
                return;
            }

            voteRepository.AddVote(new Vote
            {
                CookieId         = message.CookieId,
                IPAddress        = message.IPAddress,
                Referrer         = message.Referrer,
                ScreenResolution = message.ScreenResolution,
                SessionId        = message.SessionId,
                TimeRecorded     = message.TimeRecorded,
                UserAgent        = message.UserAgent,
                UserId           = message.UserId,
                WebSessionId     = message.WebSessionId,
                PositionInList   = message.PositionInList
            });
        }
Пример #6
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
                    WebSecurity.Login(model.UserName, model.Password);

                    // ensure the name and email address are set
                    var profile = userProfileRepository.GetUserProfileByUserName(model.UserName);
                    profile.Name         = model.FullName;
                    profile.EmailAddress = model.EmailAddress;
                    userProfileRepository.UpdateUserProfile(profile);

                    var conference      = conferenceLoader.LoadConference();
                    var registeredModel = new RegisteredModel
                    {
                        UserName          = model.UserName,
                        CanSubmitSessions = conference.CanSubmit()
                    };
                    return(View("Registered", registeredModel));
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #7
0
        private MenuViewModel CreateMenuViewModel()
        {
            var  conference      = conferenceLoader.LoadConference();
            bool showVotingStats = conference.CanVote() || conference.AgendaBeingPrepared() || conference.CanPublishAgenda() || conference.CanRegister();
            var  menuViewModel   = new MenuViewModel {
                ShowVotingStatsLink = showVotingStats
            };

            return(menuViewModel);
        }
        public void BeforeEachTest()
        {
            _voteRepository = Substitute.For<IVoteRepository>();
            _voteRepository.HasVotedFor(Arg.Any<int>(), Arg.Any<Guid>()).Returns(true);

            _conferenceLoader = Substitute.For<IConferenceLoader>();
            var conference = new Conference(1, "", "");
            _conferenceLoader.LoadConference(Arg.Is(SessionId)).Returns(conference);

            _handler = new DeleteVoteCommandHandler(_voteRepository, _conferenceLoader);
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var conference = conferenceLoader.LoadConference();

            if (conference.IsPreview())
            {
                filterContext.Result = new RedirectResult("~/Preview");
            }

            base.OnActionExecuting(filterContext);
        }
Пример #10
0
        public SessionVoteModel Get(int sessionId, Guid cookieId)
        {
            var conference = conferenceLoader.LoadConference(sessionId);

            return(new SessionVoteModel
            {
                CanVote = conference.CanVote(),
                HasBeenVotedForByUser = voteRepository.HasVotedFor(sessionId, cookieId),
                SessionId = sessionId
            });
        }
        public void BeforeEachTest()
        {
            _voteRepository = Substitute.For<IVoteRepository>();
            _voteRepository.HasVotedFor(Arg.Any<int>(), Arg.Any<Guid>()).Returns(false);

            _conferenceLoader = Substitute.For<IConferenceLoader>();
            var conference = new Conference(1, "", "");
            //            conference.AddToCalendar(ConferenceHelper.GetOpenVotingPeriod());
            _conferenceLoader.LoadConference(Arg.Is(1)).Returns(conference);

            _handler = new DeleteVoteCommandHandler(_voteRepository, _conferenceLoader);
        }
Пример #12
0
        public void BeforeEachTest()
        {
            _voteRepository = Substitute.For <IVoteRepository>();
            _voteRepository.HasVotedFor(Arg.Any <int>(), Arg.Any <Guid>()).Returns(true);

            _conferenceLoader = Substitute.For <IConferenceLoader>();
            var conference = new Conference(1, "", "");

            _conferenceLoader.LoadConference(Arg.Is(SessionId)).Returns(conference);

            _handler = new DeleteVoteCommandHandler(_voteRepository, _conferenceLoader);
        }
Пример #13
0
        public ActionResult Index()
        {
            int numberOfSessions           = conferenceLoader.LoadConference().TotalNumberOfSessions;
            int numberOfDaysOfVoting       = dataProvider.GetNumberOfDaysOfVoting();
            int numberOfDaysOfVotingPassed = Math.Min(numberOfDaysOfVoting, dataProvider.GetNumberOfDaysSinceVotingOpened());
            int votingPercentComplete      = (int)(numberOfDaysOfVotingPassed * 1.0f / numberOfDaysOfVoting * 100);
            var model = new VotingStatsViewModel
            {
                TotalVotes = dataProvider.GetTotalVoteCount(),
                NumberOfUsersWhoHaveVoted     = dataProvider.GetNumberOfUsersWhoHaveVoted(),
                NumberOfDaysOfVoting          = numberOfDaysOfVoting,
                NumberOfDaysOfVotingPassed    = numberOfDaysOfVotingPassed,
                NumberOfDaysOfVotingRemaining = dataProvider.GetNumberOfDaysUntilVotingCloses(),
                VotingCompletePercentage      = votingPercentComplete,
                VotingStartDate       = dataProvider.GetVotingStartDate(),
                VotingEndDate         = dataProvider.GetVotingEndDate(),
                TotalNumberOfSessions = numberOfSessions
            };

            return(View(model));
        }
Пример #14
0
        public void BeforeEachTest()
        {
            _voteRepository = Substitute.For <IVoteRepository>();
            _voteRepository.HasVotedFor(Arg.Any <int>(), Arg.Any <Guid>()).Returns(false);

            _conferenceLoader = Substitute.For <IConferenceLoader>();
            var conference = new Conference(1, "", "");

//            conference.AddToCalendar(ConferenceHelper.GetOpenVotingPeriod());
            _conferenceLoader.LoadConference(Arg.Is(1)).Returns(conference);

            _handler = new DeleteVoteCommandHandler(_voteRepository, _conferenceLoader);
        }
Пример #15
0
        public override void Handle(DeleteVoteCommand message)
        {
            var conference = conferenceLoader.LoadConference(message.SessionId);

            if (conference == null || !conference.CanVote())
            {
                return;
            }

            if (!voteRepository.HasVotedFor(message.SessionId, message.CookieId))
            {
                return;
            }

            voteRepository.Delete(message.SessionId, message.CookieId);
        }
Пример #16
0
//        public ActionResult Environmental()
//        {
//            return View();
//        }

        public ActionResult Accommodation()
        {
            var conference = conferenceLoader.LoadConference();

            if (!conference.CanRegister())
            {
                return(RedirectToAction("Index"));
            }

            return(View());
        }
Пример #17
0
        private string GetCookieName()
        {
            var conference = conferenceLoader.LoadConference();

            return(string.Format("{0}.Voting", conference.ShortName));
        }
 public ConferenceLoaderBuilder()
 {
     conference = Substitute.For<IConference>();
     conferenceLoader = Substitute.For<IConferenceLoader>();
     conferenceLoader.LoadConference().Returns(conference);
 }
Пример #19
0
 public ConferenceLoaderBuilder()
 {
     conference       = Substitute.For <IConference>();
     conferenceLoader = Substitute.For <IConferenceLoader>();
     conferenceLoader.LoadConference().Returns(conference);
 }