public ActionResult Index()
        {
            var model = new CalculatorViewModel();

            IEnumerable<CalculatorType> calculatorType = Enum.GetValues(typeof(CalculatorType)).Cast<CalculatorType>();
            IEnumerable<CalculatorKilo> calculatorKilo = Enum.GetValues(typeof(CalculatorKilo)).Cast<CalculatorKilo>();

            model.TypeList = GetTypeList(calculatorType, model.TypeId);
            model.KiloList = GetKiloList(calculatorKilo, model.KiloId);

            model = GetModelResult(model);

            return View(model);
        }
        public ActionResult Index(CalculatorViewModel input)
        {
            var model = new CalculatorViewModel();

            IEnumerable<CalculatorType> calculatorType = Enum.GetValues(typeof(CalculatorType)).Cast<CalculatorType>();
            IEnumerable<CalculatorKilo> calculatorKilo = Enum.GetValues(typeof(CalculatorKilo)).Cast<CalculatorKilo>();

            model.TypeList = GetTypeList(calculatorType, input.TypeId);
            model.KiloList = GetKiloList(calculatorKilo, input.KiloId);

            model.Quantity = input.Quantity;
            model.TypeId = input.TypeId;
            model.KiloId = input.KiloId;

            // Calculate
            model = GetModelResult(model);

            return View(model);
        }
        private CalculatorViewModel GetPetabitModel(CalculatorViewModel model)
        {
            double bytes = 8;
            double quantity = model.Quantity;

            var result = model;

            if (model.KiloId == 0) // Bandwidth1000
            {
                result.GetBit = quantity * bytes;
                result.GetByte = quantity;
                result.GetKilobit = quantity / (Math.Pow(10, 3));
                result.GetKilobyte = quantity / (Math.Pow(10, 3) * bytes);
                result.GetMegabit = quantity / (Math.Pow(10, 6));
                result.GetMegabyte = quantity / (Math.Pow(10, 6) * bytes);
                result.GetGigabit = quantity / (Math.Pow(10, 9));
                result.GetGigabyte = quantity / (Math.Pow(10, 9) * bytes);
                result.GetTerabit = quantity / (Math.Pow(10, 12));
                result.GetTerabyte = quantity / (Math.Pow(10, 12) * bytes);
                result.GetPetabit = quantity / (Math.Pow(10, 15));
                result.GetPetabyte = quantity / (Math.Pow(10, 15) * bytes);
                result.GetExabit = quantity / (Math.Pow(10, 18));
                result.GetExabyte = quantity / (Math.Pow(10, 18) * bytes);
                result.GetZettabit = quantity / (Math.Pow(10, 21));
                result.GetZettabyte = quantity / (Math.Pow(10, 21) * bytes);
                result.GetYottabit = quantity / (Math.Pow(10, 24));
                result.GetYottabyte = quantity / (Math.Pow(10, 24) * bytes);
            }
            else if (model.KiloId == 1) // Storage1024
            {
                result.GetBit = quantity * bytes;
                result.GetByte = quantity;
                result.GetKilobit = quantity / (Math.Pow(2, 10));
                result.GetKilobyte = quantity / (Math.Pow(2, 10) * bytes);
                result.GetMegabit = quantity / (Math.Pow(2, 20));
                result.GetMegabyte = quantity / (Math.Pow(2, 20) * bytes);
                result.GetGigabit = quantity / (Math.Pow(2, 30));
                result.GetGigabyte = quantity / (Math.Pow(2, 30) * bytes);
                result.GetTerabit = quantity / (Math.Pow(2, 40));
                result.GetTerabyte = quantity / (Math.Pow(2, 40) * bytes);
                result.GetPetabit = quantity / (Math.Pow(2, 50));
                result.GetPetabyte = quantity / (Math.Pow(2, 50) * bytes);
                result.GetExabit = quantity / (Math.Pow(2, 60));
                result.GetExabyte = quantity / (Math.Pow(2, 60) * bytes);
                result.GetZettabit = quantity / (Math.Pow(2, 70));
                result.GetZettabyte = quantity / (Math.Pow(2, 70) * bytes);
                result.GetYottabit = quantity / (Math.Pow(2, 80));
                result.GetYottabyte = quantity / (Math.Pow(2, 80) * bytes);
            }
            else
            {
                throw new ArgumentException();
            }

            return result;
        }
        private CalculatorViewModel GetModelResult(CalculatorViewModel model)
        {
            // TypeId:  
            // <option value="0">Bit</option>
            // <option value="1">Byte</option>
            // <option value="2">Kilobit</option>
            // <option value="3">Kilobyte</option>
            // <option value="4">Megabit</option>
            // <option value="5">Megabyte</option>
            // <option value="6">Gigabit</option>
            // <option value="7">Gigabyte</option>
            // <option value="8">Terabit</option>
            // <option value="9">Terabyte</option>
            // <option value="10">Petabit</option>
            // <option value="11">Petabyte</option>
            // <option value="12">Exabit</option>
            // <option value="13">Exabyte</option>
            // <option value="14">Zettabit</option>
            // <option value="15">Zettabyte</option>
            // <option value="16">Yottabit</option>
            // <option value="17">Yottabyte</option>

            // KiloId: 
            // <option value="0">Bandwidth1000</option>
            // <option value="1">Storage1024</option>

            var result = new CalculatorViewModel();

            if (model.TypeId == 0)
            {
                result = GetBitModel(model);
            }
            else if (model.TypeId == 1)
            {
                result = GetByteModel(model);
            }
            else if (model.TypeId == 2)
            {
                result = GetKilobitModel(model);
            }
            else if (model.TypeId == 3)
            {
                result = GetKilobyteModel(model);
            }
            else if (model.TypeId == 4)
            {
                result = GetMegabitModel(model);
            }
            else if (model.TypeId == 5)
            {
                result = GetMegabyteModel(model);
            }
            else if (model.TypeId == 6)
            {
                result = GetGigabitModel(model);
            }
            else if (model.TypeId == 7)
            {
                result = GetGigabyteModel(model);
            }
            else if (model.TypeId == 8)
            {
                result = GetTerabitModel(model);
            }
            else if (model.TypeId == 9)
            {
                result = GetTerabyteModel(model);
            }
            else if (model.TypeId == 10)
            {
                result = GetPetabitModel(model);
            }
            else if (model.TypeId == 11)
            {
                result = GetPetabyteModel(model);
            }
            else if (model.TypeId == 12)
            {
                result = GetExabitModel(model);
            }
            else if (model.TypeId == 13)
            {
                result = GetExabyteModel(model);
            }
            else if (model.TypeId == 14)
            {
                result = GetZettabitModel(model);
            }
            else if (model.TypeId == 15)
            {
                result = GetZettabyteModel(model);
            }
            else if (model.TypeId == 16)
            {
                result = GetYottabitModel(model);
            }
            else if (model.TypeId == 17)
            {
                result = GetYottabyteModel(model);
            }
            else
            {
                throw new ArgumentException("Invalid type");
            }

            return result;
        }