Пример #1
0
        public virtual List<State> GetAllStates()
        {
            try
            {
                var reader = File.ReadAllLines(FilePath);

                for (int i = 1; i < reader.Length; i++)
                {
                    var columns = reader[i].Split(',');

                    var state = new State();

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

                    States.Add(state);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "State Repo - GetAllStates");
            }

            return States;
        }
Пример #2
0
 public Response()
 {
     Message = "";
     Order = new Order();
     Slip = new OrderSlip();
     OrderList = new List<Order>();
     State = new State();
     Product = new Product();
 }
        public void CheckIfStateExistsTest(string stateAbbrev, bool expected)
        {
            // arrange
            var state = new State();
            state.StateAbbreviation = stateAbbrev;

            // act
            var response = ops.CheckIfStateExists(state);

            // assert
            Assert.AreEqual(expected, response.Success);
        }
Пример #4
0
        public State LoadFromCSVForTesting(string stateCSV)
        {
            var columns = stateCSV.Split(',');

            var state = new State();

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

            return state;
        }
        public void GetStateTest(string stateAbbrev, int indexOfState)
        {
            // arrange
            State state = new State();
            state.StateAbbreviation = stateAbbrev;

            // act
            var result = _repo.GetState(state);
            var actual = _repo.ToCSVForTesting(result);

            // assert
            Assert.AreEqual(_states[indexOfState], actual);
        }
Пример #6
0
        public Order CalculateOrderTotals(Order Order, State state, Product product)
        {
            Logger.Info("Calculate order Totals called", "OrderOps - CalculateOrderTotals");

            Order.CostPerSquareFoot = _productsRepository.GetProduct(product).CostPerSquareFoot;
            Order.LaborCostPerSquareFoot = _productsRepository.GetProduct(product).LaborCostPerSquareFoot;
            Order.TaxRate = _statesRepository.GetState(state).TaxRate;
            Order.LaborCost = Order.LaborCostPerSquareFoot * Order.Area;
            Order.MaterialCost = Order.CostPerSquareFoot * Order.Area;
            Order.Tax = (Order.MaterialCost + Order.LaborCost) * (Order.TaxRate / 100);
            Order.Total = Order.LaborCost + Order.MaterialCost + Order.Tax;

            return Order;
        }
Пример #7
0
        public virtual State GetState(State state)
        {
            var stateToReturn = new State();

            try
            {
                List<State> states = GetAllStates();

                stateToReturn = states.FirstOrDefault(s => s.StateAbbreviation.ToUpper() == state.StateAbbreviation.ToUpper());
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "State Repo - GetState");
            }

            return stateToReturn;
        }
        public Response CheckIfStateExists(State stateQuery)
        {
            Logger.Info("Check if state exists called", "RepoOps - CheckIfStateExists");

            var state = _statesRepository.GetState(stateQuery);

            if (state == null)
            {
                Logger.Warning("State does not exist", "RepoOps - CheckIfStateExists");
                _response.Success = false;
                return _response;
            }
            else
            {
                _response.Success = true;
                _response.State = state;
                return _response;
            }
        }
Пример #9
0
 public Order()
 {
     State = new State();
     ProductType = new Product();
 }
Пример #10
0
 public string ToCSVForTesting(State state)
 {
     return String.Format("{0},{1},{2}", state.StateAbbreviation, state.StateName, state.TaxRate);
 }
Пример #11
0
        public Response ValidateState(string stateInput)
        {
            State stateQuery = new State();

            if (stateInput.Length == 2)
            {
                Response.Success = true;
                Response.Message = "";
                stateQuery.StateAbbreviation = stateInput;
                Response.State = stateQuery;
            }
            else
            {
                Response.Success = false;
                Response.Message = "That is not a valid input...\n";
                Logger.Warning("Invalid user Input", "ValidateUserInputs - ValidateState");
            }

            return Response;
        }