Esempio n. 1
0
        public static string GetRequiredStateFromUser(string prompt, bool isEdit = false)
        {
            TaxRepository stateRepo = new TaxRepository();

            while (true)
            {
                Console.Write(prompt);
                PrintAllStates(stateRepo.Taxes());
                Console.WriteLine("Please choose a state by abbreviation");
                List <string> stateChoices = new List <string>();
                foreach (var x in stateRepo.Taxes())
                {
                    stateChoices.Add(x.StateAbbreviation.Trim(' '));
                }
                return(IsValidInput(stateChoices, isEdit));
            }
        }
Esempio n. 2
0
        public static decimal StateAssociatedTax(string stateAbbreviation)
        {
            TaxRepository taxRepo = new TaxRepository();
            Dictionary <string, decimal> stateChoices = new Dictionary <string, decimal>();

            foreach (var x in taxRepo.Taxes())
            {
                stateChoices.Add(x.StateAbbreviation, x.TaxRate);
            }
            return(stateChoices[stateAbbreviation]);
        }
Esempio n. 3
0
        public void CanReadTaxesFromFile()
        {
            TaxRepository repo = new TaxRepository();

            List <Tax> taxes = repo.Taxes();

            Assert.AreEqual(7, taxes.Count());

            Tax check = taxes[1];

            Assert.AreEqual("OH", check.StateAbbreviation);
            Assert.AreEqual("Ohio", check.StateName);
            Assert.AreEqual(7.14M, check.TaxRate);
        }
Esempio n. 4
0
        public List <Tax> GetAllStateInfo()
        {
            TaxRepository repo = new TaxRepository();

            return(repo.Taxes());
        }