public ActionResult BitCalculator(CalculatorModel calcModel) { CalculatorModel result; var types = new List<string>() { "bit - b", "Byte - B", "Kilobit - Kb", "Kilobyte - KB", "Megabit - Mb", "Megabyte - MB", "Gigabit - Gb", "Gigabyte - GB", "Terabit - Tb", "Terabyte - TB", "Petabit - Pb", "Petabyte - PB", "Exabit - Eb", "Exabyte - EB", "Zettabit - Zb", "Zettabyte - ZB", "Yottabit - Yb", }; var kilos = new List<string>() { "1024", "1000" }; if (calcModel == null) { calcModel = new CalculatorModel(); } calcModel.Types = types.Select((x, i) => new SelectListItem { Text = x, Value = i.ToString() }).ToList(); calcModel.Kilos = kilos.Select((x, i) => new SelectListItem { Text = x, Value = i.ToString() }).ToList(); if (calcModel != null && calcModel.Value != null && calcModel.SelectedType != null && calcModel.SelectedKilo != null) { calcModel.Result = new Dictionary<string, string>(); for (int i = 0; i < 10; i++) { calcModel.Result.Add(types[i], GetType( i, calcModel.Value, calcModel.SelectedKilo, calcModel.SelectedType)); } } return View(calcModel); }
public DisplayableCalculatorController() { calculator = new CalculatorModel(); displayRefreshRequired = false; Display = Constants.ZERO; FirstOperand = string.Empty; SecondOperand = string.Empty; CurrentOperationType = OperationType.NONE; LastOperationType = OperationType.NONE; NumericSystem = NumericSystemType.DECIMAL; }
public PartialViewResult ShowCalculator() { var cal = new CalculatorModel(); return PartialView(cal); }