static void HandleResponse(Task <HTTPRequest_RetailerToClientGateway> response) { MonitorObject.StopMonitoring(); Console.WriteLine("Command type received: " + response.Result.RetailCmd); Console.WriteLine("Request time: " + MonitorObject.TimeSpan); Console.WriteLine("Cookie received: " + response.Result.Cookie.CurrentCookieString); switch (response.Result.RetailCmd) { case HTTPRequest_ClientToGateway.RetailCommand.Login: ClientRequestResponse_Login.HandleLoginResponse(response); break; case HTTPRequest_ClientToGateway.RetailCommand.AddProduct: ClientRequestResponse_Basket.AddProductHandleResponse(response); break; case HTTPRequest_ClientToGateway.RetailCommand.RemoveProduct: break; case HTTPRequest_ClientToGateway.RetailCommand.ViewAllProducts: ClientRequestResponse_ViewProducts.ViewProductsHandleResponse(response); break; default: break; } }
private void LogOut() { if (!ClientRequestResponse_Login.IsLoggedIn()) { Console.WriteLine("Was already not logged in."); return; } Client_Logout.LogOut(); }
private void DisplayBasket() { if (!ClientRequestResponse_Login.IsLoggedIn()) { Console.WriteLine("ERROR - Not logged in."); return; } if (ClientSession.Basket == null) { Console.WriteLine("Cannot display basket, it is null."); return; } ClientSession.Basket.DisplayBasket(); }
void DisplayMenuOption() { Console.WriteLine("Welcome to Kwik-E-Mart."); Console.WriteLine("- - - - - - - Menu - - - - - - - -"); Console.WriteLine("Please make a selection in the menu by entering a command and pressing the >ENTER< key."); Console.WriteLine(""); Console.WriteLine("Available commands:"); Console.WriteLine("LOGIN"); //Console.WriteLine("REGISTER USER"); if (ClientRequestResponse_Login.IsLoggedIn()) { Console.WriteLine("DISPLAY BASKET"); Console.WriteLine("SEE PRODUCTS"); Console.WriteLine("ADD PRODUCT"); Console.WriteLine("LOG OUT"); } Console.WriteLine("QUIT"); Console.WriteLine(""); }
private void AddProduct() { if (!ClientRequestResponse_Login.IsLoggedIn()) { Console.WriteLine("ERROR - Not logged in."); return; } int productIDAsInt = -1; Console.WriteLine("Product ID: "); string productID = Console.ReadLine(); if (!int.TryParse(productID, out productIDAsInt)) { Console.WriteLine("ERROR - not a number."); } Console.WriteLine("Quantity: "); string quantity = Console.ReadLine(); int quantityAsInt = -1; if (!int.TryParse(quantity, out quantityAsInt)) { Console.WriteLine("ERROR - not a number."); } Product p = ClientSession.CurrentProductListDisplayed.FirstOrDefault(x => x.ID == productIDAsInt); if (p == null) { Console.WriteLine("Invalid product ID. Please update products list by typing 'see products' in the main menu."); return; } p.Quantity = quantityAsInt; //Request HTTPRequest_ClientToGateway requestAddProduct = new HTTPRequest_ClientToGateway(); #region Request setup requestAddProduct.Product = p; requestAddProduct.Cookie = ClientSession.ClientCookie; requestAddProduct.RetailCmd = HTTPRequest_ClientToGateway.RetailCommand.AddProduct; #endregion ClientRequestResponse.SendRequest(requestAddProduct); }