private static decimal GetGrandTotalFrom(ShellViewModel viewModel) { if (string.IsNullOrWhiteSpace(viewModel.GrandTotal)) return 0m; string grandTotalString = viewModel.GrandTotal.Substring(1); decimal grandTotalAmount; if (!decimal.TryParse(grandTotalString, out grandTotalAmount)) return 0m; return grandTotalAmount; }
private static ShellViewModel CreateViewModelWithBooks(int[] books) { var vm = new ShellViewModel(); foreach (var book in books) { if (book == 1) vm.Book1Quantity++; if (book == 2) vm.Book2Quantity++; if (book == 3) vm.Book3Quantity++; if (book == 4) vm.Book4Quantity++; if (book == 5) vm.Book5Quantity++; } vm.Calculate(); return vm; }