public IndexCountryViewModel(Entities.Country country)
        {
            Info = new CountryInfoViewModel(country);

            var companyRepository = DependencyResolver.Current.GetService <ICompanyRepository>();
            var companies         = companyRepository.Where(company => company.OwnerID == country.ID && company.CompanyTypeID != (int)CompanyTypeEnum.Construction).ToList();

            Companies = companies.Select(company => new CountryCompanyOnViewViewModel(company)).ToList();
        }
Esempio n. 2
0
        public CountryWarsViewModel(IQueryable <Entities.War> wars, Entities.Country country, PagingParam pagingParam, IWarService warService)
        {
            Info        = new CountryInfoViewModel(country);
            PagingParam = pagingParam;

            foreach (var war in wars.Apply(pagingParam).ToList())
            {
                WarsInfo.Add(new ShortWarInfoViewModel(war, warService));
            }
        }
        public CountryRegionsListViewModel(Entities.Country country)
        {
            foreach (var region in country.Regions
                     .OrderBy(r => r.Name)
                     .ToList())
            {
                Regions.Add(new CountryRegionViewModel(region));
            }

            Info = new CountryInfoViewModel(country);
        }
        public EmbargoesPageViewModel(Entities.Country country, IEmbargoService embargoService)
        {
            Info = new CountryInfoViewModel(country);
            foreach (var embargo in country.CreatedEmbargoes.Where(e => e.Active).ToList())
            {
                CreatedEmbargoes.Add(new EmbargoViewModel(embargo, embargoService));
            }

            foreach (var embargo in country.Embargoes.Where(e => e.Active).ToList())
            {
                Embargoes.Add(new EmbargoViewModel(embargo, embargoService));
            }
        }
Esempio n. 5
0
        public PresidentCandidatesListViewModel(Entities.PresidentVoting voting, MethodResult canCandidateResult, bool canVote)
        {
            foreach (var candidate in voting.PresidentCandidates.ToList())
            {
                Candidates.Add(new PresidentCandidateViewModel(candidate));
            }

            Info = new CountryInfoViewModel(voting.Country);

            ElectionDay  = voting.StartDay;
            CanCandidate = canCandidateResult.isSuccess;
            if (CanCandidate == false)
            {
                CannotCandidateReason = canCandidateResult.Errors[0].ToString();
            }

            IsElectionDay = voting.VotingStatusID == (int)VotingStatusEnum.Ongoing;
            CanVote       = canVote;
        }
        public DeclareEmbargoViewModel(Entities.Country country, List <Entity> possibleCountries)
        {
            Info = new CountryInfoViewModel(country);


            PossiblEmbargoes.Add(new SelectListItem()
            {
                Value = "null",
                Text  = "-- Select --"
            });

            foreach (var possibleCountry in possibleCountries)
            {
                PossiblEmbargoes.Add(new SelectListItem()
                {
                    Value = possibleCountry.EntityID.ToString(),
                    Text  = possibleCountry.Name
                });
            }
        }
        public DeclareWarViewModel(Entities.Country country, ICountryRepository countryRepository)
        {
            Info = new CountryInfoViewModel(country);
            AttackerCountryID = country.ID;

            var neighbours = getNeighboursWithoutWarWithAttacker(country, countryRepository)
                .Select(n => new { ID = n.ID, Name = n.Entity.Name })
                .ToList();

            NeighboursCountries.Add(new SelectListItem() { Text = "Select country", Value = "" });

            var allies = countryRepository.GetAllies(country.ID);

            foreach (var neighbour in neighbours)
            {
                if (allies.Any(a => a.ID == neighbour.ID))
                    continue;

                NeighboursCountries.Add(new SelectListItem() { Text = neighbour.Name, Value = neighbour.ID.ToString() });
            }
        }
        public ConstructCompanyViewModel(Entities.Country country, IRegionRepository regionRepository, IWalletService walletService, ICountryTreasureService countryTreasuryService)
        {
            Info      = new CountryInfoViewModel(country);
            CountryID = country.ID;
            var regions = regionRepository.Where(r => r.CountryID == country.ID).
                          Select(r => new
            {
                Name = r.Name,
                ID   = r.ID
            }).ToList();

            Regions   = CreateSelectList(regions, r => r.Name, r => r.ID, true);
            Functions = ProductTypeEnumUtils.GetFunctionsList();

            GoldNeeded = new MoneyViewModel(GameHelper.Gold, ConfigurationHelper.Configuration.CompanyCountryFee);
            var walletID = Persistent.Countries.GetById(country.ID).Entity.WalletID;

            TreasureGold = new MoneyViewModel(walletService.GetWalletMoney(walletID, GameHelper.Gold.ID));

            CanSeeTreasury = countryTreasuryService.CanSeeCountryTreasure(country, SessionHelper.CurrentEntity).isSuccess;
        }
Esempio n. 9
0
        public PresidentViewModel(Entities.Country country, ICountryService countryService, ICountryRepository countryRepository)
        {
            Info = new CountryInfoViewModel(country);

            var president = country.President;

            if (president != null)
            {
                PresidentName   = president.Entity.Name;
                PresidentAvatar = new ImageViewModel(president.Entity.ImgUrl);
                PresidentID     = president.ID;
            }

            var presidentElection = countryRepository.GetLastPresidentVoting(country.ID);

            if (presidentElection.VotingStatusID == (int)VotingStatusEnum.Ongoing)
            {
                IsElectionTime = true;
            }
            else
            {
                IsElectionTime     = false;
                NextElectionInDays = presidentElection.StartDay - GameHelper.CurrentDay;
            }


            var entity = SessionHelper.CurrentEntity;

            if (entity.Citizen != null)
            {
                if (entity.EntityID == PresidentID)
                {
                    IsPlayerPresident = true;
                }
                CanBeCandidate = countryService.CanCandidateAsPresident(entity.Citizen, country).isSuccess;
            }
        }
        public CountryMPPListViewModel(Entities.Country country, List <MilitaryProtectionPact> pacts,
                                       List <MilitaryProtectionPactOffer> proposedList, List <MilitaryProtectionPactOffer> proposals)
        {
            Info = new CountryInfoViewModel(country);
            foreach (var pact in pacts)
            {
                MPPs.Add(new MPPViewModel(pact));
            }
            foreach (var proposed in proposedList)
            {
                MPPs.Add(new MPPViewModel(proposed, isProposal: false));
            }
            foreach (var proposal in proposals)
            {
                MPPs.Add(new MPPViewModel(proposal, true));
            }

            var mppService = DependencyResolver.Current.GetService <IMPPService>();

            RuledCountries = mppService.GetListOfCountriesWhereCitizenCanManageMPPs(SessionHelper.LoggedCitizen)
                             .Select(c => c.ID).ToList();

            CanCreateMPPOffers = mppService.CanOfferMPP(SessionHelper.CurrentEntity, country).isSuccess;
        }
Esempio n. 11
0
 public CountryWalletViewModel(Entities.Country country, List <WalletMoney> money) : base(money)
 {
     Info = new CountryInfoViewModel(country);
 }