Example #1
0
        private async void GotoSwapProductComponent(ProductComponent productComponent)
        {
            Log.Verbose("Get compatible components of a product.");
            var progressDialog = ProgressDialog.Show(context, context.GetString(Resource.String.please_wait), context.GetString(Resource.String.loading_compatible_components), true);

            _api = new SwapComponentApi();
            string parameters = "/compatible?stockId=" + productComponent.StockId;
            ProductComponentsResponse swappableProductComponentsResponse = await _api.GetProductDetails(Uri.EscapeUriString(parameters),
                                                                                                        filterFlags : ErrorFilterFlags.AllowEmptyResponses);

            progressDialog.Hide();
            if (swappableProductComponentsResponse.Successful)
            {
                Log.Verbose("API Call successful");
                Intent intent = new Intent(context, typeof(SwappableComponentsActivity));
                //pass the product details
                Bundle extras = new Bundle();
                extras.PutString("product", JsonConvert.SerializeObject(_product));
                extras.PutString("productComponent", JsonConvert.SerializeObject(productComponent));
                extras.PutString("swappableProductComponentsResponse", JsonConvert.SerializeObject(swappableProductComponentsResponse));
                extras.PutString("productComponentsResponse", JsonConvert.SerializeObject(_productComponentsResponse));
                extras.PutString("customerDetailsResponse", JsonConvert.SerializeObject(_customerDetailsResponse));
                intent.PutExtras(extras);
                context.StartActivity(intent);
            }
            else
            {
                Log.Verbose("Something went wrong");
                if (swappableProductComponentsResponse.ResponseText.Equals("not_connected"))
                {
                    Toast.MakeText(context, context.GetString(Resource.String.not_connected), ToastLength.Long).Show();
                }
            }
        }
        private async void GetProductComponents(SwapProduct product)
        {
            Log.Verbose("Get components of a product.");
            var progressDialog = ProgressDialog.Show(this, GetString(Resource.String.please_wait), GetString(Resource.String.loading_product_components), true);

            api = new SwapComponentApi();

            if (product.ProductName.Contains("Product III"))
            {
                product.ProductName = "Product III";
            }
            string parameters = "/components?ProductName=" + product.ProductName;
            ProductComponentsResponse productComponentsResponse = await api.GetProductDetails(Uri.EscapeUriString(parameters),
                                                                                              filterFlags : ErrorFilterFlags.AllowEmptyResponses);

            progressDialog.Hide();
            if (productComponentsResponse.Successful)
            {
                Log.Verbose("API Call successful");
                //                SwapComponentsActivity.productComponentsResponse = productComponentsResponse;
                Intent intent = new Intent(this, typeof(ProductComponentsActivity));
                //pass the product details
                Bundle extras = new Bundle();
                extras.PutString("product", JsonConvert.SerializeObject(product));
                extras.PutString("productComponentsResponse", JsonConvert.SerializeObject(productComponentsResponse));
                extras.PutString("customerDetailsResponse", JsonConvert.SerializeObject(_customerDetailsResponse));
                intent.PutExtras(extras);
                StartActivity(intent);
            }
            else
            {
                Log.Verbose("Something went wrong");
                if (productComponentsResponse.ResponseText.Equals("not_connected"))
                {
                    Toast.MakeText(this, GetString(Resource.String.not_connected), ToastLength.Long).Show();
                }
            }
            //productComponentsResponse = CreateDummyResponse();
        }