Exemplo n.º 1
0
        public ListTaxResponse LoadTaxInfo(string filePath)
        {
            ListTaxResponse response = new ListTaxResponse();

            response.Success = true;
            response.TaxList = new List <TaxInfo>();

            try
            {
                using (StreamReader reader = new StreamReader(filePath))
                {
                    reader.ReadLine();
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        TaxInfo stateTax = new TaxInfo();

                        string[] columns = line.Split(',');

                        stateTax.StateAbbreviation = columns[0];
                        stateTax.StateName         = columns[1];
                        stateTax.TaxRate           = decimal.Parse(columns[2]);

                        response.TaxList.Add(stateTax);
                    }
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
Exemplo n.º 2
0
        public GetTaxRateResponse GetTaxInfo(string stateAbbreviation)
        {
            ListTaxResponse    taxResponse = _taxRepository.LoadTaxInfo(ConfigurationManager.AppSettings["TaxFilePath"].ToString());
            GetTaxRateResponse response    = new GetTaxRateResponse();

            if (taxResponse.Success)
            {
                var taxInfo = taxResponse.TaxList;

                var stateCheck = (from tax in taxInfo
                                  where tax.StateAbbreviation == stateAbbreviation
                                  select tax).ToArray();

                if (stateCheck.Any())
                {
                    response.TaxRate = stateCheck[0].TaxRate;
                    response.Success = true;
                }
                else
                {
                    response.Success = false;
                    response.Message = "We cannot do work in that state!";
                }
            }
            else
            {
                response.Success = false;
                response.Message = taxResponse.Message;
            }

            return(response);
        }
Exemplo n.º 3
0
        public ListTaxResponse LoadTaxInfo(string filePath)
        {
            ListTaxResponse response = new ListTaxResponse();

            response.Success = true;
            response.TaxList = _taxInfo;

            return(response);
        }
Exemplo n.º 4
0
        public Dictionary <string, string> GetStateList()
        {
            ListTaxResponse             taxResponse = _taxRepository.LoadTaxInfo(ConfigurationManager.AppSettings["TaxFilePath"].ToString());
            Dictionary <string, string> stateList   = new Dictionary <string, string>();

            foreach (TaxInfo tax in taxResponse.TaxList)
            {
                stateList.Add(tax.StateAbbreviation, tax.StateName);
            }

            return(stateList);
        }