public bool Deposit(string cookie, double amount) { var customer = GetCustomer(cookie); if (customer == null) { return(false); } AddTransaction(amount, null, customer); var numberOfSavedItems = bankDb.SaveChanges(); return(numberOfSavedItems == 3); }
void Register(IBankDb context, double amount, string user, string pin, string name) { var customer = new Customer() { User = HashString(user), Pin = HashString(pin), Name = name }; context.Customers.Add(customer); var transaction = new Transaction() { Amount = amount, Sender = null, Receiver = customer, Date = DateTime.Now }; context.Transactions.Add(transaction); context.SaveChanges(); context.Customers.First(x => string.Equals(x.User, customer.User)).Transactions.Add(transaction); context.SaveChanges(); }