public EmbargoCostViewModel(Entities.Country issuedCountry, Entities.Country embargoedCountry, double cost, bool haveMoney) { Cost = new MoneyViewModel(CurrencyTypeEnum.Gold, (decimal)cost); EmbargoedCountryID = embargoedCountry.ID; IssueCountryID = issuedCountry.ID; HaveMoney = haveMoney; }
public ActionResult Create(CountryVM viewModel) { try { // TODO: Add insert logic here if (ModelState.IsValid) { Entities.Country entity = new Entities.Country(); entity.CountryId = viewModel.CountryId; entity.CountryName = viewModel.CountryName; entity.Status = viewModel.Status; entity.Remark = viewModel.Remark; CountryBAL balObject = new CountryBAL(); balObject.Add(entity); return(RedirectToAction("Index")); } else { //AcademicYearBAL academicYearBAL = new AcademicYearBAL(); // viewModel.AcademicYears = from obj in academicYearBAL.GetAll() select new SelectListItem() { Text = obj.AcademicYearName, Value = obj.AcademicYearId.ToString() }; return(View(viewModel)); } } catch { //AcademicYearBAL academicYearBAL = new AcademicYearBAL(); // viewModel.AcademicYears = from obj in academicYearBAL.GetAll() select new SelectListItem() { Text = obj.AcademicYearName, Value = obj.AcademicYearId.ToString() }; return(View(viewModel)); } }
public ViewCongressViewModel(Entities.Country country) : base(country) { ActualLaw = new ActualLawViewModel(country.CountryPolicy); CongressmenCount = country.Congressmen.Count; CountryName = country.Entity.Name; NextCongressmenVoting = country.CongressCandidateVotings.Last().VotingDay; if (country.GetLastCongressCandidateVoting().VotingStatusID == (int)VotingStatusEnum.Ongoing) { IsVotingDay = true; } else if (SessionHelper.CurrentEntity.Is(EntityTypeEnum.Citizen)) { var citizen = SessionHelper.CurrentEntity.Citizen; IsCountryPartyMember = citizen.PartyMember?.Party?.CountryID == country.ID; IsInCountry = citizen.Region.CountryID == country.ID; CandidateRegion = citizen.Region.Name; if (IsCountryPartyMember) { if (country.CongressCandidateVotings.Last().CongressCandidates.Any(c => c.CandidateID == citizen.ID)) { IsCandidating = true; } } } }
public ActionResult Edit(CountryVM viewModel) { try { // TODO: Add update logic here if (ModelState.IsValid) { Entities.Country entity = new Entities.Country(); entity.CountryId = viewModel.CountryId; entity.CountryName = viewModel.CountryName; entity.Status = viewModel.Status; entity.Remark = viewModel.Remark; CountryBAL balObject = new CountryBAL(); balObject.Edit(entity); return(RedirectToAction("Index")); } else { return(View(viewModel)); } } catch { return(View()); } }
/// <summary> /// This method inserts domain block to manifes. /// </summary> /// <param name="um">instance of user menu</param> /// <param name="country">instance of country</param> /// <param name="domainNickname">domain nickname or folder name of domain</param> private void insertDomainBlockToManifest(UserMenu um, Entities.Country country, string domainNickname) { Regex regex1 = new Regex(@"^" + country.FolderName + " {"); StringBuilder sBilder = new StringBuilder(); using (StreamReader reader = new StreamReader(um.manifestAddress, Encoding.GetEncoding(1251))) { string lineFromManifest; do { lineFromManifest = reader.ReadLine(); sBilder.AppendLine(lineFromManifest); } while (!regex1.IsMatch(lineFromManifest)); Regex regex2 = new Regex(@"^}"); do { lineFromManifest = reader.ReadLine(); sBilder.AppendLine(lineFromManifest); } while (!regex2.IsMatch(lineFromManifest)); sBilder.Append(domainNickname + " {\n}\n"); sBilder.Append(reader.ReadToEnd()); } using (StreamWriter sr = new StreamWriter(um.manifestAddress, false, Encoding.GetEncoding(1251))) { sr.Write(sBilder.ToString()); } }
public CongressInfoViewModel(Entities.Country country) { CountryName = country.Entity.Name; CountryID = country.ID; MemberCount = country.Congressmen.Count; CongressImageViewModel = Images.GetCountryFlag(country).VM; CadencyDaysLeft = country.GetLastCongressCandidateVoting().VotingDay - GameHelper.CurrentDay; }
private IQueryable<Entities.Country> getNeighboursWithoutWarWithAttacker(Entities.Country country, ICountryRepository countryRepository) { return countryRepository.GetNeighbourCountries(country.ID) .Where(n => n.AttackerWars.Any(w => w.Active && (w.AttackerCountryID == AttackerCountryID || w.DefenderCountryID == AttackerCountryID)) == false) .Where(n => n.DefenderWars.Any(w => w.Active && (w.AttackerCountryID == AttackerCountryID || w.DefenderCountryID == AttackerCountryID)) == false); }
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(); }
public PartiesListViewModel(Entities.Country country, List <Entities.Party> parties, PagingParam pagingParam) { CountryID = country.ID; CountryName = country.Entity.Name; PagingParam = pagingParam; foreach (var party in parties) { Infos.Add(new PartyInfoViewModel(party)); } }
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); }
/// <summary> /// Updates the given <see cref="Country"/>. /// </summary> /// <param name="countryId">Id of the object being updated.</param> /// <param name="country">The <see cref="Country"/> to update.</param> /// <param name="cancellationToken">Cancellation Token</param> /// <returns>The updated <see cref="Country"/>.</returns> public virtual async Task <Entities.Country> UpdateAsync(long countryId, Entities.Country country, CancellationToken cancellationToken = default) { var req = PrepareRequest($"countries/{countryId}.json"); var content = new JsonContent(new { country = country }); var response = await ExecuteRequestAsync <Entities.Country>(req, HttpMethod.Put, cancellationToken, content, "country"); return(response.Result); }
private void initCountries(Entities.Country currentCountry, IList <Entities.Country> countries) { foreach (var country in countries) { CountryList.Add(new SelectListItem() { Text = country.Entity.Name, Value = country.ID.ToString(), Selected = country.ID == currentCountry.ID }); } }
public OfferMPPViewModel(Entities.Country country, IMPPService mppService, IWalletService walletService) { Info = new CountryInfoViewModel(country); CountrySelect = Select2AjaxViewModel.Create <CountryController>(c => c.GetMPPAvailableCountries(null, 0), "OtherCountryID", null, ""); CountrySelect.AddAdditionalData("countryID", country.ID); MinimumLength = ConfigurationHelper.Configuration.MinimumMPPLength; MaximumLength = ConfigurationHelper.Configuration.MaximumMPPLength; CountryGold = walletService.GetWalletMoney(country.Entity.WalletID, GameHelper.Gold.ID).Amount; GoldImage = Images.GetCountryCurrency(GameHelper.Gold).VM; }
public CountryMarketOffersListViewModel(Entities.Entity entity, Entities.Country currentCountry, IList <MarketOfferModel> offers, IList <Entities.Country> countries, IList <int> allowedProductTypes, PagingParam pagingParam, int quality, int productID) { Info = new CountryInfoViewModel(currentCountry); var marketService = DependencyResolver.Current.GetService <IMarketService>(); foreach (var offer in offers) { Offers.Add(new MarketOfferViewModel(entity, offer, marketService)); } initSelf(currentCountry, countries, allowedProductTypes, pagingParam, quality, productID); }
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)); } }
public static bool Where(this Entities.PublishingHouse publishingHouse, Entities.Country country) { if (publishingHouse == null) { throw new System.ArgumentNullException(nameof(publishingHouse)); } if (country == null) { throw new System.ArgumentNullException(nameof(country)); } return(publishingHouse.Country == country); }
public DeclareWarInformationsViewModel(Entities.Country declaringCountry, double goldNeeded, List <Entities.Country> attackerAllies, List <Entities.Country> defenderAllies) { GoldNeeded = new MoneyViewModel(CurrencyTypeEnum.Gold, (decimal)goldNeeded); foreach (var ally in attackerAllies) { AttackerAllies.Add(new ShortCountryInfoViewModel(ally)); } foreach (var ally in defenderAllies) { DefenderAllies.Add(new ShortCountryInfoViewModel(ally)); } CountryGold = new MoneyViewModel(declaringCountry.Entity.Wallet.GetMoney(CurrencyTypeEnum.Gold, Persistent.Currencies.GetAll())); CountryName = declaringCountry.Entity.Name; }
// // GET: /SysAdmin/Country/Details/5 public ActionResult Details(int id) { CountryVM viewModel = new CountryVM(); CountryBAL balObject = new CountryBAL(); IQueryable <Entities.Country> entites = balObject.FindBy(a => a.CountryId == id); if (entites != null && entites.Count() > 0) { Entities.Country entity = entites.FirstOrDefault(); viewModel.CountryId = entity.CountryId; viewModel.CountryName = entity.CountryName; viewModel.Status = entity.Status; viewModel.Remark = entity.Remark; } return(View(viewModel)); }
private void initSelf(Entities.Country currentCountry, IList <Entities.Country> countries, IList <int> allowedProductTypes, PagingParam pagingParam, int quality, int productID) { PagingParam = pagingParam; CountryID = currentCountry.ID; ProductID = productID; Quality = quality; SelectListItem emptyItem = new SelectListItem() { Text = "-- Select --", Value = "0" }; initProducts(allowedProductTypes, emptyItem); initQuality(emptyItem); initCountries(currentCountry, countries); }
public CountryInfoViewModel(Entities.Country country) { CountryImage = new ImageViewModel(Images.GetCountryFlag(country.Entity.Name)); CountryName = country.Entity.Name; CountryID = country.ID; var countrySerivce = DependencyResolver.Current.GetService <ICountryService>(); IsPresident = countrySerivce.IsPresident(country, SessionHelper.CurrentEntity); var countryTreasuryService = DependencyResolver.Current.GetService <ICountryTreasureService>(); CanSeeTreasury = countryTreasuryService.CanSeeCountryTreasure(country, SessionHelper.CurrentEntity).isSuccess; var policy = country.CountryPolicy; CanConstructCompany = policy.CountryCompanyBuildLawAllowHolder != (int)LawAllowHolderEnum.Congress; createMenu(); }
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; }
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 CountrySummaryViewModel(Entities.Country country) : base(SessionHelper.Session) { CountryID = country.ID; var entity = country.Entity; CountryName = entity.Name; Avatar = Images.GetCountryFlag(CountryName).VM; AdminMoney = new MoneyViewModel(entity.Wallet.GetMoney(CurrencyTypeEnum.Gold, Persistent.Currencies.GetAll())); CountryMoney = new MoneyViewModel(entity.Wallet.GetMoney(country.CurrencyID, Persistent.Currencies.GetAll())); var foreignMoney = entity.Wallet.WalletMoneys .Where(wm => wm.CurrencyID != country.CurrencyID && wm.CurrencyID != (int)CurrencyTypeEnum.Gold && wm.Amount > 0) .OrderByDescending(wm => wm.Amount) .Take(3); foreach (var money in foreignMoney) { ForeignMoney.Add(new MoneyViewModel(Persistent.Currencies.First(c => c.ID == money.CurrencyID), money.Amount)); } }
public JobMarketBestViewModel(Entities.Country country, CountryBestJobOffers best) { CurrencySymbol = country.Currency.Symbol; MaximumSalary = (int)Math.Ceiling(best.MaximumSalary ?? 10); MaximumSkill = (double)Math.Ceiling((double?)best.MaximumSkill ?? 10.0); if (MinimumSalary == MaximumSalary) { MaximumSalary += 1; } if (Math.Abs(MaximumSkill - MinimumSkill) < 0.00001) { MaximumSkill += 1; } //let it be for now. It's the best option i think? MinimumSalary = 0; MinimumSkill = 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; }
public List <Entities.Country> GetAllCountries() { var countries = new List <Entities.Country>(); DbCommand dbCommand = null; try { using (dbCommand = database.GetStoredProcCommand(DBStoredProcedure.GetListOfAllCountries)) { using (IDataReader reader = database.ExecuteReader(dbCommand)) { while (reader.Read()) { var country = new Entities.Country { CountryId = DRE.GetNullableInt32(reader, "country_id", 0), CountryName = DRE.GetNullableString(reader, "country_name", null), CountryCode = DRE.GetNullableString(reader, "country_code", null) }; countries.Add(country); } } } } catch (Exception ex) { throw ex; } finally { dbCommand = null; } return(countries); }
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 void Init(Entities.Country country) { Info = new CongressInfoViewModel(country); }
public CongressBase(Entities.Country country) { Init(country); }