コード例 #1
0
        public CongressMemberSectionViewModel(List <Entities.Congressman> unorderedCongressmen, Entities.Country country, IPartyRepository partyRepository)
        {
            Info = new CongressInfoViewModel(country);

            var congressmenOrderedByParty = unorderedCongressmen.GroupBy(c => c.Citizen?.PartyMember?.PartyID)
                                            .OrderByDescending(x => x.Count());

            var partysIDs = congressmenOrderedByParty.Select(c => c.Key).ToList();

            var parties = partyRepository.Where(p => partysIDs.Contains(p.ID)).ToList();

            foreach (var congressmen in congressmenOrderedByParty)
            {
                var party = parties.FirstOrDefault(p => p.ID == congressmen.Key);

                OrderedMembersByParty.Add(new CongressMembersListViewModel(congressmen.ToList(), party));
            }
        }
コード例 #2
0
        public CongressCandidateSectionViewModel(Entities.Country country)
        {
            Info           = new CongressInfoViewModel(country);
            CountryRegions = CreateSelectList(country.Regions.ToList(), true, "Select Region");
            CountryRegions.Add(new SelectListItem()
            {
                Text = "All regions", Value = "ALL"
            });
            CountryParties = CreateSelectList(country.Parties.ToList(), p => p.Entity.Name, p => p.ID, true, "Select Party");

            var lastVoting = country.GetLastCongressCandidateVoting();

            if (SessionHelper.CurrentEntity.Is(EntityTypeEnum.Citizen))
            {
                CanVote = !lastVoting.HasVoted(SessionHelper.LoggedCitizen) &&
                          lastVoting.VotingStatusID == (int)VotingStatusEnum.Ongoing;
            }

            VotingStatus = (VotingStatusEnum)lastVoting.VotingStatusID;
            CountryID    = country.ID;
            VotingDay    = lastVoting.VotingDay;
            DaysLeft     = lastVoting.VotingDay - GameHelper.CurrentDay;
        }
コード例 #3
0
 public void Init(Entities.Country country)
 {
     Info = new CongressInfoViewModel(country);
 }
コード例 #4
0
 public CandidateViewModel(Entities.Country country)
 {
     Info = new CongressInfoViewModel(country);
 }