예제 #1
0
파일: Payment.cs 프로젝트: mejas/raisins
        public int ConvertPaymentAmountToVotes()
        {
            int    convertedAmount = (int)(Amount * Currency.ExchangeRate);
            string currencyCode    = Currency.CurrencyCode;

            if (currencyCode == "PHP")
            {
                PaymentCategory paymentCategory = new PaymentCategory
                {
                    PlatinumPaymentAmount = 2000, PlatinumPaymentVotes = 55,
                    GoldPaymentAmount     = 1000, GoldPaymentVotes = 25,
                    SilverPaymentAmount   = 500, SilverPaymentVotes = 12,
                    BronzePaymentAmount   = 50, BronzePaymentVotes = 1
                };

                return(NumberOfVotes(convertedAmount, paymentCategory));
            }
            else if (currencyCode == "USD")
            {
                PaymentCategory paymentCategory = new PaymentCategory
                {
                    PlatinumPaymentAmount = 40, PlatinumPaymentVotes = 55,
                    GoldPaymentAmount     = 20, GoldPaymentVotes = 25,
                    SilverPaymentAmount   = 10, SilverPaymentVotes = 12,
                    BronzePaymentAmount   = 1, BronzePaymentVotes = 1
                };
                return(NumberOfVotes((int)Amount, paymentCategory));
            }
            else
            {
                return((int)(Amount / Currency.Ratio));
            }
        }
예제 #2
0
파일: Payment.cs 프로젝트: mejas/raisins
        public int NumberOfVotes(int paymentAmount, PaymentCategory paymentCategory)
        {
            if (paymentCategory == null)
            {
                throw new ArgumentNullException("paymentCategory", "Payment Category is null");
            }

            int platinumPayment        = paymentAmount / paymentCategory.PlatinumPaymentAmount * paymentCategory.PlatinumPaymentVotes;
            int goldPortionOfPayment   = paymentAmount % paymentCategory.PlatinumPaymentAmount;
            int goldPayment            = goldPortionOfPayment / paymentCategory.GoldPaymentAmount * paymentCategory.GoldPaymentVotes;
            int silverPortionOfPayment = goldPortionOfPayment % paymentCategory.GoldPaymentAmount;
            int silverPayment          = silverPortionOfPayment / paymentCategory.SilverPaymentAmount * paymentCategory.SilverPaymentVotes;
            int bronzePortionOfPayment = silverPortionOfPayment % paymentCategory.SilverPaymentAmount;
            int bronzePayment          = bronzePortionOfPayment / paymentCategory.BronzePaymentAmount * paymentCategory.BronzePaymentVotes;

            return(platinumPayment + goldPayment + silverPayment + bronzePayment);
        }