public void CalculateTipTest()
        {
            var calculator = new TipCalculator();
            var request = new TipCalculationRequest {MealCost = 100, TipPercent = .2M};
            var result = calculator.CalculateTip(request);

            Assert.AreEqual(result.TipAmount, 20M);
            Assert.AreEqual(result.TotalCost, 120M);
        }
        public TipCalculationResponse CalculateTip(TipCalculationRequest request)
        {
            var response = new TipCalculationResponse();
              response.TipPercent = request.TipPercent;
              response.MealCost = request.MealCost;
              response.TipAmount = response.TipPercent*response.MealCost;
              response.TotalCost = response.MealCost + response.TipAmount;

              response.TipAmount = Math.Round(response.TipAmount, 2); //limits response to two decimal places for currency
              response.TotalCost = Math.Round(response.TotalCost, 2);
              return response;
        }
        public ActionResult TipCalculator(TipCalculatorRequest request)
        {
            if (ModelState.IsValid)
            {
                var calc = new TipCalculator();

                var tipData = new MVCappLabs.Models.Level1.TipCalculationRequest();
                tipData.MealCost   = request.MealCost.Value;
                tipData.TipPercent = request.TipPercent.Value / 100;

                var response = calc.CalculateTip(tipData);

                return(View("TipCalculatorResponse", response));
            }
            return(View("TipCalculator"));
        }
        public ActionResult TipCalculator(TipCalculatorRequest request)
        {
            if (ModelState.IsValid)
            {

                var calc = new TipCalculator();

                var tipData = new MVCappLabs.Models.Level1.TipCalculationRequest();
                tipData.MealCost = request.MealCost.Value;
                tipData.TipPercent = request.TipPercent.Value / 100;

                var response = calc.CalculateTip(tipData);

                return View("TipCalculatorResponse", response);

            }
            return View("TipCalculator");
        }