Exemplo n.º 1
0
        public PartialViewResult DisplayVotingInfo(VotingTypeEnum votingType, int votingID)
        {
            var voting = congressVotingRepository.GetById(votingID);
            CongressVotingViewModel vm = CongressVotingViewModelChooser.GetViewModel(votingType, voting);

            return(PartialView(vm));
        }
Exemplo n.º 2
0
        public static CongressVotingViewModel GetViewModel(VotingTypeEnum votingType, int countryID)
        {
            Type            type = GetType(votingType);
            ConstructorInfo ctor = type.GetConstructor(new[] { typeof(int) });

            return((CongressVotingViewModel)ctor.Invoke(new object[] { countryID }));
        }
 private void AddMoreVotingTypesBasedOnPolicy(VotingTypeEnum votingType)
 {
     VotingTypes.Add(new SelectListItem()
     {
         Text  = votingType.ToHumanReadable(),
         Value = ((int)votingType).ToString()
     });
 }
Exemplo n.º 4
0
        private static bool isVotingEnumAlawaysVotable(VotingTypeEnum value)
        {
            var type       = typeof(VotingTypeEnum);
            var memInfo    = type.GetMember(value.ToString());
            var attributes = memInfo[0].GetCustomAttributes(typeof(AlwaysVotableAttribute), false);

            return(((AlwaysVotableAttribute)attributes[0]).Value);
        }
Exemplo n.º 5
0
        public static Type GetType(VotingTypeEnum votingType)
        {
            foreach (var type in VotingViewModelsTypes)
            {
                if (type.Key == votingType)
                {
                    return(type.Value);
                }
            }

            throw new KeyNotFoundException("CongressVotingViewModel not found");
        }
Exemplo n.º 6
0
        private static ViewVotingBaseViewModel instantiate(VotingTypeEnum votingType, CongressVoting voting, bool isPlayerCongressman, bool canVote)
        {
#if DEBUG
            if (viewModelTypes.Count != Enum.GetValues(typeof(VotingTypeEnum)).Length)
            {
                throw new Exception("Something is propably wrong here :D");
            }
#endif

            var type = viewModelTypes[votingType];
            var ctor = type.GetConstructor(new[] { typeof(CongressVoting), typeof(bool), typeof(bool) });

            return((ViewVotingBaseViewModel)ctor.Invoke(new object[] { voting, isPlayerCongressman, canVote }));
        }
Exemplo n.º 7
0
        private static void add <T>(VotingTypeEnum votingType)
            where T : class
        {
            var type = typeof(T);

#if DEBUG
            if (viewModelTypes.ContainsKey(votingType))
            {
                throw new Exception("We have that type!(" + votingType.ToString() + ")");
            }
#endif

            viewModelTypes.Add(votingType, type);
        }
        private ProductTaxTypeEnum getProductTaxType(VotingTypeEnum votingType)
        {
            switch (votingType)
            {
            case VotingTypeEnum.ChangeProductVAT:
                return(ProductTaxTypeEnum.VAT);

            case VotingTypeEnum.ChangeProductImportTax:
                return(ProductTaxTypeEnum.Import);

            case VotingTypeEnum.ChangeProductExportTax:
                return(ProductTaxTypeEnum.Export);
            }

            throw new NotImplementedException();
        }
Exemplo n.º 9
0
        public static string ToHumanReadable(this VotingTypeEnum votingType)
        {
            switch (votingType)
            {
            case VotingTypeEnum.ChangeMinimumContractLength:
                return("Change minimum contract length");

            case VotingTypeEnum.ChangeMaximumContractLength:
                return("Change maximum contract length");

            case VotingTypeEnum.ChangeCongressVotingLength:
                return("Change congress voting length");

            case VotingTypeEnum.ChangePartyPresidentCadenceLength:
                return("Change party president cadence length");

            case VotingTypeEnum.ChangeCongressCadenceLength:
                return("Change congress cadence length");

            case VotingTypeEnum.ChangeNormalJobMarketFee:
                return("Change normal job market fee");

            case VotingTypeEnum.ChangeContractJobMarketFee:
                return("Change contract job market fee");

            case VotingTypeEnum.ChangeProductVAT:
                return("Change product vat");

            case VotingTypeEnum.ChangeProductImportTax:
                return("Change product import tax");

            case VotingTypeEnum.ChangeProductExportTax:
                return("Change product export tax");

            case VotingTypeEnum.ChangeArticleTax:
                return("Change article tax");

            case VotingTypeEnum.ChangeNewspaperCreateCost:
                return("Change newspaper create cost");

            case VotingTypeEnum.ChangeMarketOfferCost:
                return("Change market offer cost");

            case VotingTypeEnum.ChangeOrganisationCreateCost:
                return("Change organisation create cost");

            case VotingTypeEnum.ChangePresidentCadenceLength:
                return("Change president cadence length");

            case VotingTypeEnum.ChangePartyCreateFee:
                return("Change party creation fee");

            case VotingTypeEnum.ChangeNormalCongressVotingWinPercentage:
                return("Change normal congress voting win percentage");

            case VotingTypeEnum.ChangeCitizenCompanyCost:
                return("Change citizen company cost");

            case VotingTypeEnum.ChangeOrganisationCompanyCost:
                return("Change organisation company cost");

            case VotingTypeEnum.ChangeMonetaryTaxRate:
                return("Change monetary tax rate");

            case VotingTypeEnum.ChangeMinimumMonetaryTaxValue:
                return("Change minimum monetary tax value");

            case VotingTypeEnum.ChangeTreasureLawHolder:
                return("Change who can see the treasury");

            case VotingTypeEnum.ChangeCompanyCreationLawHolder:
                return("Change who can create national companies");

            case VotingTypeEnum.CreateNationalCompany:
                return("Create national company");

            case VotingTypeEnum.RemoveNationalCompany:
                return("Remove national company");

            case VotingTypeEnum.AssignManagerToCompany:
                return("Assign manager to company");

            case VotingTypeEnum.TransferCashToCompany:
                return("Transfer money to company");

            case VotingTypeEnum.ChangeGreetingMessage:
                return("Change greeting message");

            case VotingTypeEnum.ChangeCitizenStartingMoney:
                return("Change citizen starting money");

            case VotingTypeEnum.PrintMoney:
                return("Print money");

            case VotingTypeEnum.ChangeMinimalWage:
                return("Change minimal wage");

            case VotingTypeEnum.BuildDefenseSystem:
                return("Build defense system");

            case VotingTypeEnum.ChangeHouseTax:
                return("Change house tax");

            case VotingTypeEnum.ChangeHotelTax:
                return("Change hotel tax");
            }
            throw new NotImplementedException();
        }
Exemplo n.º 10
0
 public List <CongressVoting> GetNotFinishedVotings(int countryID, VotingTypeEnum votingType)
 {
     return(Where(v => v.CountryID == countryID && v.VotingTypeID == (int)votingType &&
                  (v.VotingStatusID == (int)VotingStatusEnum.NotStarted || v.VotingStatusID == (int)VotingStatusEnum.Ongoing))
            .ToList());
 }
Exemplo n.º 11
0
        public PartialViewResult EditOptionForm(VotingTypeEnum votingType, int countryID)
        {
            CongressVotingViewModel vm = CongressVotingViewModelChooser.GetViewModel(votingType, countryID);

            return(PartialView(vm));
        }
Exemplo n.º 12
0
        public static CongressVotingViewModel GetViewModel(VotingTypeEnum votingType, CongressVoting voting)
        {
            Type type = GetType(votingType);

            return((CongressVotingViewModel)Activator.CreateInstance(type, voting));
        }
Exemplo n.º 13
0
        public static CongressVotingViewModel GetViewModel(VotingTypeEnum votingType, FormCollection values)
        {
            Type type = GetType(votingType);

            return((CongressVotingViewModel)Activator.CreateInstance(type, values));
        }