using LegacyUnitTesting.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace LegacyUnitTesting.Controllers
{
    public class ShippingManager : Controller
    {
        public static decimal SalesTax = 0.13m;

        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult ShipProduct(IProduct prod, int qty, ShippingUrgency urg)
        {
            //…some code…

            decimal shipCost = CalcShipCost(prod, qty, urg);

            //…more code…
            ShipAcceptModel model = new ShipAcceptModel();
            model.ShipCost = shipCost;
            return View(model);
        }

        private decimal CalcShipCost(IProduct prod, int qty, ShippingUrgency urg)
        {
            decimal extraCharges = 0;
            bool areExtraCharges = false;

            //code that I realize will be different if we ship using some other method
            decimal shippingCost = 0;
            if (prod.weight > 100)
            {
                shippingCost += 100 * SalesTax;
            }
            if (qty < 50) { }
            switch (urg)
            {
                case ShippingUrgency.High:
                    break;
            }

            //…lots more of that code 

            //code that I realize is independent of how we ship the product
            if (areExtraCharges)
            {
                shippingCost += extraCharges;
            }
            //…lots more of that code…

            return shippingCost;
        }
    }
}