public static void buyAction() { Console.WriteLine("please enter the commodity Id"); string commodityInput = Console.ReadLine(); int commodity = ezer(commodityInput); while (commodity == -1) { commodityInput = Console.ReadLine(); commodity = ezer(commodityInput); } Console.WriteLine("please enter the amount"); string amountInput = Console.ReadLine(); int amount = ezer(amountInput); while (amount == -1) { amountInput = Console.ReadLine(); amount = ezer(amountInput); } Console.WriteLine("please enter the price"); string priceInput = Console.ReadLine(); int price = ezer(priceInput); while (price == -1) { priceInput = Console.ReadLine(); price = ezer(priceInput); } DAL.MarketClient m = new DAL.MarketClient(); try { m.SendBuyRequest(price, commodity, amount); } catch (DAL.Utils.MarketException mx) { Console.WriteLine(mx.Message.ToString()); } catch (AggregateException ax) { Console.WriteLine("The server isn't working at the momment, please try again later"); } }
/// <summary> /// Sends a requet to purchase given amount of commodity for given price. /// </summary> public static void buyAction() { Console.WriteLine("> Please enter the commodity Id:"); string commodityInput = Console.ReadLine(); int commodity = inputCheck2(commodityInput); if (commodity == -1) { return; } Console.WriteLine("> Please enter the amount:"); string amountInput = Console.ReadLine(); int amount = inputCheck1(amountInput); if (amount == -1) { return; } Console.WriteLine("> Please enter the price:"); string priceInput = Console.ReadLine(); int price = inputCheck1(priceInput); if (price == -1) { return; } DAL.MarketClient m = new DAL.MarketClient(); try { m.SendBuyRequest(price, commodity, amount); } catch (DAL.Utils.MarketException mx) { Console.WriteLine(mx.Message.ToString()); } catch (AggregateException ax) { ServerCrashError(); } }