public void ParseCommand() { _command = Console.ReadLine(); string[] command = _command.Split(" "); if (command[0].StartsWith(":")) { bool success = false; if (_adminCommands.ContainsKey(command[0])) { _adminCommands[command[0]].Invoke(); success = true; } if (success == false) { ui.DisplayAdminCommandNotFoundMessage(_command); } } else if (command.Length == 2) { try { string user = command[0]; int productID = int.Parse(command[1]); if (ProductSuccess(productID) && UserSucess(user)) { BuyTransaction buy = ss.BuyProduct(ss.GetUserByUsername(user), ss.GetProductByID(productID)); ss.LogTransaction(buy, @"C:\Users\T-Phamz\Desktop\test.txt"); ui.DisplayUserBuysProduct(buy); ss.OnUserBalanceWarning(ss.GetUserByUsername(user)); } } catch (FormatException) { Console.WriteLine($"{(command[1])} is not a positive integer"); } catch (InsufficientCreditsException) { ui.DisplayInsufficientCash(ss.GetUserByUsername(command[0]), ss.GetProductByID(int.Parse(command[1]))); } catch (ProductNotActiveException ex) { ui.DisplayGeneralError(ex.Message); } } else if (command.Length == 3) { try { string user = command[0]; int numberOfItems = int.Parse(command[1]); int productID = int.Parse(command[2]); if (ProductSuccess(productID) && UserSucess(user) && numberOfItems > 0) { BuyTransaction buy = null; for (int i = 0; i < numberOfItems; i++) { buy = ss.BuyProduct(ss.GetUserByUsername(user), ss.GetProductByID(productID)); ss.LogTransaction(buy, @"C:\Users\T-Phamz\Desktop\test.txt"); } ui.DisplayUserBuysProduct(numberOfItems, buy); ss.OnUserBalanceWarning(ss.GetUserByUsername(user)); } else { ui.DisplayGeneralError($"Number of items bought ({command[1]}) can not be under 1"); } } catch (FormatException) { Console.WriteLine($"{(command[1])} or {(command[2])} " + $"is not a number"); } catch (InsufficientCreditsException) { ui.DisplayInsufficientCash(ss.GetUserByUsername(command[0]), ss.GetProductByID(int.Parse(command[1]))); } catch (ProductNotActiveException ex) { ui.DisplayGeneralError(ex.Message); } } else if (command.Length == 1) { if (UserSucess(command[0])) { User u = ss.GetUserByUsername(command[0]); ui.DisplayUserInfo(u); foreach (Transaction item in ss.GetTransactions(u, 10)) { ui.DisplayTransactions(item); } ss.OnUserBalanceWarning(u); } } else { ui.DisplayTooManyArgumentsError($"\"{_command}\""); } Console.WriteLine(); }