void TryLogin() { WebRequestHandler wrh = GetComponent <WebRequestHandler>(); Player p = GetComponent <Player>(); p.SetName(playerNameField.text); string requestJSONData = JsonUtility.ToJson(p.myData); loadingScreen.SetActive(true); StartCoroutine(wrh.Post("login", requestJSONData, (string jsonData) => { // success loadingScreen.SetActive(false); LoginResponse loginResponse = JsonUtility.FromJson <LoginResponse>(jsonData); p.myData = loginResponse.player; loginScreen.SetActive(false); attackScreen.SetActive(true); ingameInfoText.text = "Your Name: " + p.myData.name + " Your ID: " + p.myData.id; }, (string message) => { // fail Debug.Log("Error: " + message); loadingScreen.SetActive(false); })); }
public async void RemoveFromCart() { var handler = new WebRequestHandler(); await handler.Post("http://localhost/ShoppingCartAPI/ShoppingCart/DeleteItem", SelectedCartItem); if (SelectedCartItem == null) { return; } if (Cart.Any(i => i.Id.Equals(SelectedCartItem.Id))) { var cartItem = Cart.FirstOrDefault(i => i.Id.Equals(SelectedCartItem.Id)); if (cartItem.Units > 1) { Cart.FirstOrDefault(i => i.Id.Equals(cartItem.Id)).decUnits(); } else { Cart.Remove(cartItem); } } SelectedCartItem = null; NotifyPropertyChanged("SelectedCartItem"); NotifyPropertyChanged("Total"); NotifyPropertyChanged("Subtotal"); NotifyPropertyChanged("Taxes"); }
public bool Login() { var mainPage = _webRequestHandler.Get("https://www.darkorbit.com").Content; const string pattern = @"class=""bgcdw_login_form"" action=""https:\/\/sas\.bpsecure\.com\/Sas\/Authentication\/Bigpoint\?authUser=22&token=(.*)"""; var authToken = WebUtility.HtmlDecode(mainPage.RegExp(pattern)); var response = _webRequestHandler.Post("https://sas.bpsecure.com/Sas/Authentication/Bigpoint?authUser=22&token=" + authToken, new KeyValuePair <string, object>("username", WebUtility.HtmlEncode(Username)), new KeyValuePair <string, object>("password", WebUtility.HtmlEncode(Password))); _content = response.Content; _uri = response.ResponseUri.AbsoluteUri; var status = _uri.Contains("indexInternal.es"); _loggedIn = status; return(status); }
public async void AddToCart() { var product = SelectedProduct; var handler = new WebRequestHandler(); await handler.Post("http://localhost/ShoppingCartAPI/ShoppingCart/AddItem", product); if (SelectedProduct == null) { return; } if (Cart.Any(i => i.Id.Equals(SelectedProduct.Id))) { //Cart.FirstOrDefault(i => i.Id.Equals(SelectedProduct.Id)).Units++; Cart.FirstOrDefault(i => i.Id.Equals(SelectedProduct.Id)).incUnits(); } else { //Cart.Add(new Product { Name = SelectedProduct.Name, Description = SelectedProduct.Description, UnitPrice = SelectedProduct.Price, Units = 1, Id = SelectedProduct.Id }); if (SelectedProduct.Type == ProductType.ProductByQuantity) { Cart.Add(new ProductbyQuantity { Name = SelectedProduct.Name, Description = SelectedProduct.Description, Cost = SelectedProduct.Price, Quantity = 1, Id = SelectedProduct.Id }); } else if (SelectedProduct.Type == ProductType.ProductByWeight) { Cart.Add(new ProductbyWeight { Name = SelectedProduct.Name, Description = SelectedProduct.Description, Cost = SelectedProduct.Price, Ounces = 1, Id = SelectedProduct.Id }); } } SelectedProduct = null; NotifyPropertyChanged("SelectedProduct"); NotifyPropertyChanged("Taxes"); NotifyPropertyChanged("Subtotal"); NotifyPropertyChanged("Total"); }