Esempio n. 1
0
        public PartyCongressCandidateSectionViewModel(Entities.Party party, IPartyService partyService) : base(party.Country)
        {
            Info    = new PartyInfoViewModel(party);
            PartyID = party.ID;

            var entity     = SessionHelper.CurrentEntity;
            var lastVoting = party.Country.GetLastCongressCandidateVoting();


            var candidate = lastVoting.CongressCandidates.FirstOrDefault(c => c.CandidateID == entity.EntityID);

            if (candidate != null)
            {
                PlayerCongressCandidateStatus = (CongressCandidateStatusEnum)candidate.CongressCandidateStatusID;
            }
            if (entity.Citizen != null)
            {
                if (partyService.CanAcceptCongressCandidates(entity.Citizen, party))
                {
                    CanAcceptCandidates = true;
                }

                if (partyService.CanCandidateToCongress(entity.Citizen, party))
                {
                    CanCandidate        = true;
                    CandidateRegionName = entity.GetCurrentRegion().Name;
                }
            }
        }
Esempio n. 2
0
        public PartyMemberListViewModel(Entities.Party party, List <PartyMember> members)
        {
            Info = new PartyInfoViewModel(party);

            var president = members.FirstOrDefault(m => m.PartyRoleID == (int)PartyRoleEnum.President);

            if (president != null)
            {
                President = new SmallEntityAvatarViewModel(president.Citizen.Entity);
            }

            Managers = members.Where(m => m.PartyRoleID == (int)PartyRoleEnum.Manager)
                       .Select(m => new SmallEntityAvatarViewModel(m.Citizen.Entity)).ToList();

            Members = members.Where(m => m.PartyRoleID == (int)PartyRoleEnum.Member)
                      .Select(m => new SmallEntityAvatarViewModel(m.Citizen.Entity)).ToList();
        }
Esempio n. 3
0
        public ManagePartyViewModel(Entities.Party party, List <PartyRole> partyRoles, List <JoinMethod> joinMethods)
        {
            OverallInfo        = new PartyInfoViewModel(party);
            this.UserPartyRole = OverallInfo.PartyRole;
            this.JoinMethod    = (JoinMethodEnum)party.JoinMethodID;
            this.PartyAvatar   = OverallInfo.PartyAvatar;
            this.PartyID       = party.ID;

            partyRoles = partyRoles.Where(r => r.ID < (int)OverallInfo.PartyRole).ToList();

            foreach (var member in party.PartyMembers
                     .Where(m => m.PartyRoleID < (int)UserPartyRole)

                     .ToList())
            {
                Members.Add(new ManagePartyMemberViewModel(member));
            }

            PartyRoles  = CreateSelectList(partyRoles, x => ((PartyRoleEnum)x.ID).ToHumanReadable(), x => x.ID, true);
            JoinMethods = CreateSelectList(joinMethods);
        }
        public PartyCandidateListViewModel(PartyPresidentVoting voting)
        {
            var candidates = voting.PartyPresidentCandidates.ToList();

            Info = new PartyInfoViewModel(voting.Party);

            foreach (var candidate in candidates)
            {
                Add(new PartyCandidateViewModel(candidate));
            }

            VotingStatus = (VotingStatusEnum)voting.VotingStatusID;

            var entity = SessionHelper.CurrentEntity;

            if (entity.EntityTypeID == (int)(EntityTypeEnum.Citizen) && voting.VotingStatusID == (int)VotingStatusEnum.Ongoing)
            {
                if (voting.PartyPresidentVotes.Any(v => v.CitizenID == entity.EntityID) == false)
                {
                    CanVote = true;
                }
            }
        }
 public PartyPendingInviteListViewModel(Entities.Party party, List <Entity> citizens)
 {
     Info = new PartyInfoViewModel(party);
     CitizensWithInvites = citizens.Select(c => new SmallEntityAvatarViewModel(c)).ToList();
 }
        public ViewPartyViewModel(Entities.Party party)
        {
            InviteSelector          = Select2AjaxViewModel.Create <CitizenController>(c => c.GetCitizens(null), "citizenID", null, "");
            InviteSelector.OnChange = "inviteCitizen";

            OverallInfo = new PartyInfoViewModel(party);
            JoinMethod  = (JoinMethodEnum)party.JoinMethodID;
            PartyRole   = OverallInfo.PartyRole;
            PartyID     = party.ID;

            var members = party.PartyMembers
                          .ToList();

            var president = members
                            .FirstOrDefault(m => m.PartyRoleID == (int)PartyRoleEnum.President);

            if (president != null)
            {
                President = new ShortEntityInfoViewModel(president.Citizen.Entity);
            }

            Managers = members
                       .Where(m => m.PartyRoleID == (int)PartyRoleEnum.Manager)
                       .Take(3)
                       .Select(m => new ShortEntityInfoViewModel(m.Citizen.Entity))
                       .ToList();

            if (Managers.Count < 3)
            {
                Members = members
                          .Where(m => m.PartyRoleID == (int)PartyRoleEnum.Member)
                          .Take(3 - Managers.Count)
                          .Select(m => new ShortEntityInfoViewModel(m.Citizen.Entity))
                          .ToList();
            }

            OtherMemberCount = members.Count() - Managers.Count - Members.Count - (president == null ? 0 : 1);

            var partyVoting = party.PartyPresidentVotings.Last();
            var entity      = SessionHelper.CurrentEntity;

            if (entity.EntityTypeID == (int)EntityTypeEnum.Citizen)
            {
                if (partyVoting.PartyPresidentCandidates.Any(c => c.CitizenID == entity.EntityID))
                {
                    CanStartAsCandidate = false;
                }
            }

            VotingDay = partyVoting.VotingDay;
            DaysLeft  = Math.Abs(GameHelper.CurrentDay - VotingDay);
            var candidatesID = partyVoting.PartyPresidentCandidates
                               .Select(c => c.CitizenID);

            VotingStatus = (VotingStatusEnum)partyVoting.VotingStatusID;
            IsCandidate  = candidatesID.Contains(entity.EntityID);
            if (VotingStatus == VotingStatusEnum.NotStarted && entity.EntityTypeID == (int)EntityTypeEnum.Citizen &&
                IsCandidate == false
                )
            {
                CanCandidate = true;
            }

            if (VotingStatus == VotingStatusEnum.Ongoing)
            {
                if (partyVoting.PartyPresidentVotes.Any(v => v.CitizenID == entity.EntityID) == true)
                {
                    Voted = true;
                }
            }

            var country        = party.Country;
            var congressVoting = country.GetLastCongressCandidateVoting();

            CongressCandidateVotingViewModel = new CongressCandidateVotingShortViewModel(congressVoting);

            InviteSelector.AddAdditionalData("partyid", PartyID);

            if (JoinMethod == JoinMethodEnum.Invite && PartyRole != PartyRoleEnum.NotAMember)
            {
                PendingInvites = party.PartyInvites.Count();
            }
        }
 public PartyJoinRequestsListViewModel(Entities.Party party, List <PartyJoinRequest> requests)
 {
     Info     = new PartyInfoViewModel(party);
     Requests = requests.Select(request => new PartyJoinRequestsListItemViewModel(request)).ToList();
 }