public Dictionary<int, List<Money>> GetCash(int[] amount) { Dictionary<int, List<Money>> moneyDictionary = new Dictionary<int, List<Money>>(); MoneyBankDBTool mbDBTool = new MoneyBankDBTool(); for (var i = 0; i < amount.Length; i++) { moneyDictionary.Add(MoneyBank.MoneyGenerator.MoneySequence[i], mbDBTool.FetchMoney(i, amount[i])); } if (ValidateFetchedMoney(moneyDictionary, amount)) mbDBTool.DeleteFetchedMoney(moneyDictionary); else throw new Exception("Fail to retrieve the money"); return moneyDictionary; }
public static bool GenerateMoney(Consignment consignment) { Dictionary<int, List<Money>> moneyDictionary = new Dictionary<int, List<Money>>(); int value; int[] moneyMultiplier = GetMultiplierArray(consignment); try { for (var i = 0; i < moneyMultiplier.Length; i++) { List<Money> moneyList = new List<Money>(); value = MoneySequence[i]; for (var j = 0; j < moneyMultiplier[i]; j++) { Money money = new Money(value); moneyList.Add(money); } moneyDictionary.Add(value, moneyList); } MoneyBankDBTool mdDBTool = new MoneyBankDBTool(); mdDBTool.InsertMoney(moneyDictionary); } catch (Exception) { return false; } return true; }