public override void Execute() { if (!HasEnoughArguments(3)) { barcodeCli.DisplayNotEnoughArguments(Command); return; } string username = Command[1]; string amountString = Command[2]; try { User user = barcodeSystem.GetUserByUsername(username); if (decimal.TryParse(amountString, out decimal amount)) { transaction = barcodeSystem.AddCreditsToAccount(user, amount); barcodeCli.DisplayAddCreditsTransaction(transaction); Succeeded = true; } } catch (UserNotFoundException) { barcodeCli.DisplayUserNotFound(username); } base.Execute(); }
protected bool TryGetProduct() { if (!HasEnoughArguments(2)) { barcodeCli.DisplayNotEnoughArguments(Command); return(false); } string productIdString = Command[1]; try { uint productId = Convert.ToUInt32(productIdString); product = barcodeSystem.GetProductById(productId); } catch (Exception) { barcodeCli.DisplayProductNotFound(productIdString); return(false); } return(true); }