public static void DisplayResult() { try { if (Input == null) { throw new ArgumentNullException(); } int _decimal; int.TryParse(Input, out _decimal); if (_decimal != 0) { DecimalModel decimalModel = new DecimalModel(); if (decimalModel != null) { decimalModel.Decimal = _decimal; decimalModel.DisplayResult(); LogModel.InputLog.Add($"{_decimal} was converted to {decimalModel.ConvertedNumeral}"); } } else { RomanModel romanModel = new RomanModel(); if (romanModel != null) { romanModel.Numeral = Input; if (romanModel.Numeral != null) { romanModel.DisplayResult(); LogModel.InputLog.Add($"{Input.ToUpper()} was converted to {romanModel.ConvertedDecimal}"); } } } } catch (ArgumentException e) { MessageBox.Show("Invalid input"); } }
private Tuple <RomanModel, RomanModel> GetUpAndDown(int number) { RomanModel up = null; RomanModel down = null; if (romanModel.Any(p => p.Value > number)) { up = (from m in romanModel.Where(p => p.Value > number) orderby m.Value select m).First(); } if (romanModel.Any(p => p.Value < number)) { down = (from m in romanModel.Where(p => p.Value < number) orderby m.Value descending select m).First(); } return(new Tuple <RomanModel, RomanModel>(down, up)); }