private void Plus(object sender, RoutedEventArgs e) { Button button = sender as Button; Item item = new Item(); item = button.DataContext as Item; var request = new RestRequest(Method.PUT); request.AddParameter("Type", "change_quantity"); ItemNevim2 nevim = new ItemNevim2(); nevim.ItemId = item.Id; if (item.Quantity >= 250) { MessageBox.Show("Maximální počet kusů je 250", "Info", MessageBoxButton.OK, MessageBoxImage.Information); } else { nevim.Quantity = item.Quantity + 1; request.AddParameter("Data", SimpleJson.SerializeObject(nevim)); var response = client.Execute <Input>(request); Shared.ShowInfo(response.Content); this.NavigationService.Navigate(new CartPage()); } }
private void Minus(object sender, RoutedEventArgs e) { Button button = sender as Button; Item item = new Item(); item = button.DataContext as Item; var request = new RestRequest(Method.PUT); request.AddParameter("Type", "change_quantity"); ItemNevim2 nevim = new ItemNevim2(); nevim.ItemId = item.Id; if (item.Quantity <= 1) { //MessageBox.Show("", "Info", MessageBoxButton.OK, MessageBoxImage.Information); //Button button = sender as Button; //Item item2 = button.DataContext as Item; var request2 = new RestRequest(Method.DELETE); request2.AddParameter("Type", "delete_item_from_order"); //ItemNevim nevim = new ItemNevim(); //nevim.Id = item2.Id; //nevim.OrderId = //nevim.Quantity = request2.AddParameter("Data", SimpleJson.SerializeObject(nevim)); var response2 = client.Execute <Input>(request2); Shared.ShowInfo(response2.Content); this.NavigationService.Navigate(new CartPage()); } else { nevim.Quantity = item.Quantity - 1; request.AddParameter("Data", SimpleJson.SerializeObject(nevim)); var response = client.Execute <Input>(request); Shared.ShowInfo(response.Content); this.NavigationService.Navigate(new CartPage()); } }