public void DisplayUserBuysProduct(BuyTransaction transaction) { Console.Clear(); Console.WriteLine("Buy transation:"); Console.WriteLine(transaction.ToString()); Console.ReadKey(); }
public void DisplayUserBuysProduct(int count, BuyTransaction transaction) { Console.Clear(); Console.WriteLine($"Buy transaction. nr {count}"); Console.WriteLine(transaction.ToString()); Console.ReadKey(); }
public BuyTransaction BuyProduct(User user, Product product) { BuyTransaction buyTrans = new BuyTransaction(user, product.Price, product); _transactionList.Add(buyTrans); if (user.Balance < 50) { OnUserBalanceWarning(user, user.Balance); } LogTransaction(buyTrans.ToString()); return(buyTrans); }
public int BuyProduct(User user, Product product) { try { BuyTransaction buyTransaction = new BuyTransaction(user, product.Price); TrackTransaction(buyTransaction); Logger.WriteMessage(buyTransaction.ToString() + " Product Name & ID: " + product.Name + product.Id); } catch (InsufficientCreditsException e) { Logger.WriteMessage("ID:" + user.Id + " There were not enough credits on the user's account"); return(1); } // Trigger event to notify user if (user.Money <= 2000) { PushNotification?.Invoke(this, new UserBalanceNotificationArgs(user.Money)); } return(0); }