Esempio n. 1
0
        public GetStatesResponse GetStates(GetStatesRequest request)
        {
            GetStatesResponse     response = new GetStatesResponse();
            IEnumerable <dynamic> states;

            states = repository.GetStates(request.CountryCode);
            if (states == null)
            {
                throw new ResourceNotFoundException("The requested states list was not found.");
            }
            response.States = states;
            return(response);
        }
Esempio n. 2
0
        public GetStatesResponse GetStates()
        {
            GetStatesResponse response = new GetStatesResponse();

            try
            {
                response.StateTaxes = _taxRepo.GetStateTaxes().ToList();
                response.Success    = true;
                return(response);
            }
            catch (Exception e)
            {
                response.Success = false;
                response.Message = "Error: something went wrong getting info from the state tax repository. Contact IT.\n" + $"(System Error Message: {e.Message})";
                return(response);
            }
        }
Esempio n. 3
0
        private static StateTax GetTax(Manager manager)
        {
            bool              validState         = false;
            StateTax          tax                = null;
            GetStatesResponse stateTaxesResponse = manager.GetStates();

            if (stateTaxesResponse.Success)
            {
                while (!validState)
                {
                    Console.Clear();
                    ConsoleIO.TitleHeader("Add an Order");
                    Console.WriteLine("(Step 3 of 5)\n");
                    ConsoleIO.PrintStateTaxInfo(stateTaxesResponse.StateTaxes);
                    string             stateAbbreviation = ConsoleIO.GetStateFromUser();
                    CheckStateResponse stateResponse     = manager.CheckForRequestedState(stateAbbreviation);
                    validState = stateResponse.Success;
                    if (!validState)
                    {
                        Console.Clear();
                        Console.WriteLine(stateResponse.Message);
                        Console.Write("Press any key to continue...");
                        Console.ReadKey();
                    }
                    else
                    {
                        tax = stateResponse.Tax;
                    }
                }
            }
            else
            {
                Console.WriteLine(stateTaxesResponse.Message);
            }
            return(tax);
        }
Esempio n. 4
0
        public HttpResponseMessage GetStates(string countryCode)
        {
            GetStatesResponse response = geoService.GetStates(new GetStatesRequest(countryCode));

            return(Request.BuildResponse(response));
        }