Example #1
0
        public static void DonorCmds()
        {
            _Doner = new Donor();
            // I've commented out this line because it's trying to talk to a db that doesn't exist
            // In a live system I would use repository pattern to get the data

            //decimal tax = repository
            //              .GetTaxByCode("5RT6").TaxRate;
            decimal tax = 20.00M;

            ValidateInput validInput = new ValidateInput();

            Console.WriteLine("Please Enter donation amount:");
            string s = Console.ReadLine();
            if (validInput.IsDecimal(s))
            {
                _Doner.DonationAmount = validInput.RoundTwoDecimalPlaces(validInput.ConvertToDecimal(s));
                Console.WriteLine("Gift aid is: £" + _Doner.CalculateGiftAid(_Doner.DonationAmount, tax).ToString());
                QuitApp("donor");
            }
            else
            {
                Console.WriteLine("Unrecognised number. Please try again.");
                DonorCmds();
            }
        }
Example #2
0
        public static void EventPromoterCmds()
        {
            Console.WriteLine("What event are you sponsoring..?"
               + Environment.NewLine +
               "Type running, swimming or other.");
            string cmd = Console.ReadLine().ToLower();
            #region options
            if (cmd == "running")
            {
                _Promoter = new EventsPromoterRunning();
            }
            else if (cmd == "swimming")
            {
                _Promoter = new EventsPromoterSwimming();
            }
            else
            {
                _Promoter = new EventsPromoterOther();
            }
            #endregion

            decimal tax = 20.00M;
            ValidateInput validInput = new ValidateInput();

            Console.WriteLine("Please Enter donation amount:");
            string s = Console.ReadLine();
            if (validInput.IsDecimal(s))
            {
                _Promoter.DonationAmount = validInput.RoundTwoDecimalPlaces(validInput.ConvertToDecimal(s));
                Console.WriteLine("Gift aid is: £" + _Promoter.CalculateGiftAid(_Promoter.DonationAmount, tax).ToString());
                QuitApp("event promoter");
            }
            else
            {
                Console.WriteLine("Unrecognised number. Please try again.");
                EventPromoterCmds();
            }
        }
Example #3
0
        public static void SiteAdminCmds()
        {
            _SiteAdministrator = new SiteAdministrator();
            Console.WriteLine("Enter new tax rate:");
            string s = Console.ReadLine();
            ValidateInput validInput = new ValidateInput();

            if (validInput.IsDecimal(s))
            {
                decimal rate = validInput.RoundTwoDecimalPlaces(validInput.ConvertToDecimal(s));
                _SiteAdministrator.SetTaxRate(rate);

                Console.WriteLine("New tax rate is: " + rate + "%");
                QuitApp("site administrator");
            }
            else
            {
                Console.WriteLine("Not a valid number.");
                QuitApp("site administrator");
            }
        }