private void ViewProducts() { //Display a list of products for the user. Inform them they must log in to access the shop. HTTPRequest_ClientToGateway requestViewProducts = new HTTPRequest_ClientToGateway(); #region Request setup requestViewProducts.RetailCmd = HTTPRequest_ClientToGateway.RetailCommand.ViewAllProducts; requestViewProducts.Cookie = ClientSession.ClientCookie; #endregion ClientRequestResponse.SendRequest(requestViewProducts); }
private void Login() { string userName = ""; string password = ""; Console.WriteLine("Username: "******"Password: "); password = Console.ReadLine(); HTTPRequest_ClientToGateway requestLogin = new HTTPRequest_ClientToGateway(); #region Request setup requestLogin.RetailCmd = HTTPRequest_ClientToGateway.RetailCommand.Login; requestLogin.User = new User(userName, password); #endregion ClientRequestResponse.SendRequest(requestLogin); }
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); }