Exemplo n.º 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();
                }
            }
        }
Exemplo n.º 2
0
        private async void SwapComponent()
        {
            SwapComponentRequest request = new SwapComponentRequest
            {
                RequestType         = _customerDetailsResponse.IdentifierType,
                RequestValue        = _customerDetailsResponse.Identifier,
                IncomingComponentId = _incomingProductComponent.StockId,
                OutgoingComponentId = _outgoingProductComponent.StockId,
                Reason = reason,
            };

            Log.Verbose("Swap details RequestType= " + request.RequestType + ",RequestValue= " + request.RequestValue
                        + " Incoming ComponentId= " + request.IncomingComponentId + " Outgoing ComponentId= " + request.OutgoingComponentId
                        + ",Reason " + request.Reason);
            Log.Verbose("Get components of a product.");
            var progressDialog = ProgressDialog.Show(this, GetString(Resource.String.please_wait), GetString(Resource.String.swapping_component), true);

            api = new SwapComponentApi();
            SwapComponentResponse swapComponentResponse = await api.SwapComponent(request);

            progressDialog.Hide();

            Intent intent = null;
            Bundle extras = new Bundle();

            extras.PutString("product", JsonConvert.SerializeObject(_product));
            extras.PutString("customerDetailsResponse", JsonConvert.SerializeObject(_customerDetailsResponse));
            extras.PutString("productComponentsResponse", JsonConvert.SerializeObject(_productComponentsResponse));
            if (swapComponentResponse.Success)
            {
                Log.Verbose("Swap was successful");
                intent = new Intent(this, typeof(SwapSuccessfulActivity));
            }
            else
            {
                Log.Verbose("Something went wrong - Swap failed");
                intent = new Intent(this, typeof(SwapFailedActivity));
                //                extras.PutInt("stockId", _incomingProductComponent.StockId);
                //                extras.PutString("reason", reason);
                extras.PutString("incomingProductComponent", JsonConvert.SerializeObject(_incomingProductComponent));
                extras.PutString("outgoingProductComponent", JsonConvert.SerializeObject(_outgoingProductComponent));
                extras.PutString("reason", reason);
                extras.PutString("swapComponentResponse", JsonConvert.SerializeObject(swapComponentResponse));
            }
            //pass the product details
            intent.PutExtras(extras);
            StartActivity(intent);
        }
Exemplo n.º 3
0
        public override void SetListeners()
        {
            api = new SwapComponentApi();
            tryAgainButton.Click += delegate
            {
                if (!maxRetriesReached)
                {
                    TryAgain();
                }
                else
                {
                    SwapAnother();
                }
            };

            cancelButton.Click += delegate
            {
                Intent intent = new Intent(this, typeof(HomeView));
                StartActivity(intent);
            };
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        private async void GetCustomerDetails()
        {
            Log.Verbose("Get details of a customer.");
            var progressDialog = ProgressDialog.Show(context, GetString(Resource.String.please_wait), GetString(Resource.String.loading_customer_details), true);

            api = new SwapComponentApi();
            string parameters = "/customer?id=" + _identifier + "&RequestType=" + _identifierType;
            bool   isOnline   = Resolver.Instance.Get <IConnectivityService>().HasConnection();

            if (!isOnline)
            {
                Toast.MakeText(context, GetString(Resource.String.unable_to_continue_net),
                               ToastLength.Long).Show();
                errorTextView.Visibility = ViewStates.Invisible;
                progressDialog.Hide();
            }
            else
            {
                CustomerDetailsResponse customerDetailsResponse = await api.GetCustomerDetails(parameters);

                progressDialog.Hide();
                if (customerDetailsResponse.Successful)
                {
                    Log.Verbose("API Call successful");
                    if (!customerDetailsResponse.CustomerFound)
                    {
                        findCustomerButton.Enabled = false;
                        errorTextView.Text         = GetString(Resource.String.customer_not_exist_reenter) + " " + identifierTypeMessage;
                        errorTextView.Visibility   = ViewStates.Visible;
                    }
                    else if (customerDetailsResponse.AccountStatus == AccountStatus.Blocked)
                    {
                        findCustomerButton.Enabled = false;
                        errorTextView.Text         = GetString(Resource.String.blocked_customer_account);
                        errorTextView.Visibility   = ViewStates.Visible;
                    }
                    else if (customerDetailsResponse.AccountStatus == AccountStatus.Cancelled)
                    {
                        findCustomerButton.Enabled = false;
                        errorTextView.Text         = GetString(Resource.String.cancelled_customer_account);
                        errorTextView.Visibility   = ViewStates.Visible;
                    }
                    else
                    {
                        customerDetailsResponse.IdentifierType = _identifierType;
                        customerDetailsResponse.Identifier     = _identifier;
                        Bundle extras = new Bundle();
                        extras.PutString("customerDetailsResponse", JsonConvert.SerializeObject(customerDetailsResponse));
                        Intent intent = new Intent(context, typeof(CustomerDetailsActivity));
                        intent.PutExtras(extras);
                        StartActivity(intent);
                    }
                }
                else
                {
                    Log.Verbose("something went wrong");
                    errorTextView.Text       = GetString(Resource.String.connection_error);
                    errorTextView.Visibility = ViewStates.Visible;
                }
            }
        }