private async Task DeleteProductAction(Product item)
        {
            var response = await AppPopupInputService.ShowMessageOkCancelAlertPopup("Remove Product", "Are you sure to remove product?", "OK", "CANCEL");

            if (!response.Equals("ok", StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            ThreadingHelpers.InvokeOnMainThread(() =>
            {
                Orders.Remove(item);
                var orders = Orders.ToList();
                Orders.Clear();
                Orders = null;
                Orders = orders;

                if (IsOrderAvailable)
                {
                    OrderSubmitText = "SUBMIT ORDER";
                }
                else
                {
                    OrderSubmitText   = "PLACE ORDER";
                    OrdersHeadingText = "No order has been placed.";
                }
            }
                                                );
        }
Exemplo n.º 2
0
        private async Task SubmitProductsAction()
        {
            if (Products == null || Products.Count == 0)
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("Submit Product", "No product available to submit.", "OK");

                return;
            }

            var selectedPrdCount = Products.Count(p => p.IsSubmitted);

            if (selectedPrdCount == 0)
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("Submit Product", "Please select one product to submit.", "OK");

                return;
            }

            // save to db
            try
            {
                AppSpinner.ShowLoading();

                var response = await _services.UserService.SaveOrders(Products, UserDetails, SupplierId);

                AppSpinner.HideLoading();

                if (response.Data != null)
                {
                    ThreadingHelpers.InvokeOnMainThread(async() =>
                                                        await AppNavigationService.GoToAsync(nameof(UserDashboardPage).ToLower(),
                                                                                             (UserDashboardPageViewModel vm) =>
                    {
                        vm.UserDetails = App.UserDetails;
                        vm.Products    = Products;
                        vm.Orders      = response.Data;
                    })
                                                        );
                }
                else
                {
                    await AppPopupInputService.ShowMessageOkAlertPopup("Submit Product", "Unable to place order. Please try again.", "OK");
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 3
0
        public async Task DeleteProductAction(Product item)
        {
            var response = await AppPopupInputService.ShowMessageOkCancelAlertPopup("Remove Product", "Are you sure to remove product?", "OK", "CANCEL");

            if (!response.Equals("ok", StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            ThreadingHelpers.InvokeOnMainThread(() =>
            {
                Products.Remove(item);
                var prds = Products.ToList();
                Products.Clear();
                Products = null;
                Products = prds;
            }
                                                );
        }
        private async Task NextButtonTapped()
        {
            if (SelectedProductType != null)
            {
                if (Product.ProductTypeId == 0)
                {
                    Product.ProductTypeId = SelectedProductType.ProductTypeId;
                    Product.ProductType   = SelectedProductType.ProductTypeName;
                }
            }

            if (SelectedProductCategory != null)
            {
                if (Product.ProductCategoryId == 0)
                {
                    Product.ProductCategoryId = SelectedProductCategory.ProductCategoryId;
                    Product.ProductCategory   = SelectedProductCategory.ProductCategoryName;
                }
            }

            if (Product.Quantity == 0)
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("Add Product", "Quantity cannot be zero.", "OK");

                return;;
            }

            if (Product.ProductTypeId == 0)
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("Add Product", "Please select product type.", "OK");

                return;;
            }

            if (Product.ProductCategoryId == 0)
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("Add Product", "Please select product category.", "OK");

                return;;
            }
            //ThreadingHelpers.InvokeOnMainThread(async () =>
            //    await AppNavigationService.GoToAsync(nameof(ChatPage).ToLower(),
            //        (ChatPageViewModel vm) =>
            //        {

            //        })
            //    );

            try
            {
                if (ProductList == null)
                {
                    ProductList = new List <Product>();
                }

                if (IsAddProduct)
                {
                    ProductList.Add(Product);
                }

                ThreadingHelpers.InvokeOnMainThread(async() =>
                                                    await AppNavigationService.GoToAsync(nameof(ReviewProductsPage).ToLower(),
                                                                                         (ReviewProductsPageViewModel vm) =>
                {
                    vm.UserDetails = UserDetails;
                    vm.Products    = ProductList;
                })
                                                    );
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 5
0
 public async void OnSleep()
 {
     // In the case of Upgrade alert popup, we are closing it down when the app goes to background.
     await AppPopupInputService.CloseLastPopup();
 }
Exemplo n.º 6
0
        private async Task SubmitProductsAction()
        {
            if (Products == null || Products.Count == 0)
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("Submit Product", "No product available to submit.", "OK");

                return;
            }

            try
            {
                AppSpinner.ShowLoading();

                // Save to backend DB
                var response = await _services.UserService.SaveProduct(Products, UserDetails.UserId);

                AppSpinner.HideLoading();

                if (response.Data)
                {
                    var productTypes = App.MasterData.ProductCategoryList.Select(l => l.ProductTypeId).Distinct();

                    int?supplierId = null;

                    switch (App.UserDetails.UserTypeId)
                    {
                    case 1:     // SUPPLIER
                        supplierId = App.UserDetails.UserId.Value;
                        break;

                    case 2:     //CONSUMER
                        break;

                    case 3:     // VOLUNTEER
                        break;

                    default:
                        break;
                    }

                    List <Product> prdList = new List <Product>();

                    foreach (var item in productTypes)
                    {
                        var products = await _services.UserService.GetUserProducts(App.UserDetails.UserId.Value,
                                                                                   supplierId, item);

                        if (products.Data.Item1 != null && products.Data.Item1.Count > 0)
                        {
                            prdList.AddRange(products.Data.Item1);
                        }
                    }

                    ThreadingHelpers.InvokeOnMainThread(async() =>
                                                        await AppNavigationService.GoToAsync(nameof(UserDashboardPage).ToLower(),
                                                                                             (UserDashboardPageViewModel vm) =>
                    {
                        vm.UserDetails = App.UserDetails;
                        vm.Products    = prdList;
                    })
                                                        );
                }
                else
                {
                    await AppPopupInputService.ShowMessageOkAlertPopup("Submit Product", response.ErrorMessage, "OK");
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 7
0
        private async Task <bool> ValidateFields()
        {
            if (string.IsNullOrWhiteSpace(UserDetails.UserName))
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("User Registration", "Please enter user name", "OK");

                return(false);
            }

            if (string.IsNullOrWhiteSpace(UserDetails.UserSecret))
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("User Registration", "Please enter password", "OK");

                return(false);
            }

            if (string.IsNullOrWhiteSpace(UserDetails.FirstName))
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("User Registration", "Please enter first name", "OK");

                return(false);
            }

            if (string.IsNullOrWhiteSpace(UserDetails.Email))
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("User Registration", "Please enter email", "OK");

                return(false);
            }

            if (string.IsNullOrWhiteSpace(UserDetails.Phone))
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("User Registration", "Please enter phone", "OK");

                return(false);
            }

            if (string.IsNullOrWhiteSpace(UserDetails.AddressLine1) && !ShouldUseCurrentLocation)
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("User Registration", "Please enter address", "OK");

                return(false);
            }

            if (UserDetails.Pin == 0 && !ShouldUseCurrentLocation)
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("User Registration", "Please enter pin code", "OK");

                return(false);
            }

            if (UserDetails.StateId == 0 && !ShouldUseCurrentLocation)
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("User Registration", "Please select state", "OK");

                return(false);
            }

            if (UserDetails.CountryId == 0 && !ShouldUseCurrentLocation)
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("User Registration", "Please select country", "OK");

                return(false);
            }

            if (!UserDetails.UserTypeId.Equals(2) && UserDetails.ProductTypeIds.Count == 0)
            {
                await AppPopupInputService.ShowMessageOkAlertPopup("User Registration", "Please select one service type", "OK");

                return(false);
            }

            return(true);
        }