Ejemplo n.º 1
0
 private async Task BindData(string postParam)
 {
     Post = QueryStringHelpers.GetData <Post>(postParam);
     if (Post._links != null && Post._links.author != null && Post._links.author.Any())
     {
         var user = QueryStringHelpers.GetData <UserInfo>(postParam);
         UserName   = user.name;
         UserAvatar = user.avatar_urls?.Avatar48;
     }
 }
Ejemplo n.º 2
0
        private async Task Processing(string orderParam)
        {
            await Task.Delay(300);

            await SetBusyAsync(async() =>
            {
                Order = QueryStringHelpers.GetData <OrderModel>(orderParam);
                if (Order != null)
                {
                    ReceiverName    = Order.Shipping.FirstName + " " + Order.Shipping.LastName;
                    ShippingAddress = Order.Shipping.Address1 + " " + Order.Shipping.Address2 + " " + Order.Shipping.City + " " + Order.Shipping.Postcode;
                }
            });
        }
Ejemplo n.º 3
0
        private async Task Processing(string postListParam)
        {
            await Task.Delay(300);

            var postListParamRequest = QueryStringHelpers.GetData <PostListParamModel>(postListParam);

            PageTitle = postListParamRequest?.WpCategoryName;

            await SetBusyAsync(async() => await WebRequestExecuter.Execute(async() => await _appService.GetAllPostsByCategory(postListParamRequest.WpCategoryId), async articles =>
            {
                if (articles != null)
                {
                    Articles = new ObservableCollection <Post>(articles);
                }
            }));
        }
Ejemplo n.º 4
0
        private async Task InitData(string cartParam)
        {
            ShippingAddress = "You don't have a shipping address";
            bool hasShipppingAddress = false;
            int  customerId          = 0;

            CustomerInfo = await _wooCommerceService.GetCustomerInfo(GlobalSettings.User.Id);

            if (CustomerInfo != null && CustomerInfo.Shipping != null && !string.IsNullOrEmpty(CustomerInfo.Shipping.Address1))
            {
                ShippingAddress     = CustomerInfo.Shipping.Address1;
                hasShipppingAddress = true;
            }

            Name = GlobalSettings.User.Name;

            var taxRatesListRequest = new TaxRatesListRequest();
            await WebRequestExecuter.Execute(async() => await _wooCommerceService.GetTaxRates(taxRatesListRequest), myTaxRates =>
            {
                if (myTaxRates.Count != 0)
                {
                    TaxRates       = new ObservableCollection <TaxRatesModel>(myTaxRates);
                    DefaultTaxRate = TaxRates.FirstOrDefault();
                }
                return(Task.CompletedTask);
            });

            var carts = QueryStringHelpers.GetData <List <CartItemModel> >(cartParam);

            Carts = new ObservableCollection <CartItemModel>(carts);

            UpdateOrderSummaryUI();

            var paymentMethods = await _wooCommerceService.GetPaymentMethods();

            if (paymentMethods != null)
            {
                PaymentMethods = paymentMethods.Where(x => x.Enabled).OrderBy(x => x.Order).ToList();
                SelectedMethod = PaymentMethods.FirstOrDefault();

                UpdateSelectedPaymentMethod();
            }

            bool isGranted = await AppHelpers.RequestPermission(Permission.Location);

            if (isGranted && !hasShipppingAddress)
            {
                var myPosition = await AppHelpers.GetCurrentPosition();

                if (myPosition != null)
                {
                    try
                    {
                        var placemarks = await Geocoding.GetPlacemarksAsync(myPosition.Latitude, myPosition.Longitude);

                        var place = placemarks.FirstOrDefault();

                        ShippingAddress    = $"{place.FeatureName} {place.Thoroughfare ?? place.SubThoroughfare}, {place.SubAdminArea}, {place.AdminArea}";
                        MapCameraInitPoint = $"{place.Location.Latitude}, {place.Location.Longitude}, 13, 30, 60";

                        var pin = new Pin
                        {
                            Type     = PinType.Place,
                            Label    = place.CountryName,
                            Address  = place.FeatureName,
                            Icon     = BitmapDescriptorFactory.FromBundle(GlobalSettings.AppConst.StorePinImage),
                            Position = new Xamarin.Forms.GoogleMaps.Position(myPosition.Latitude, myPosition.Longitude)
                        };
                        MessagingCenter.Send(pin, MessagingCenterKeys.OnDrawMapsPinSelectedStore);
                    }
                    catch (FeatureNotSupportedException fnsEx)
                    {
                        // Feature not supported on device
                    }
                    catch (Exception ex)
                    {
                        // Handle exception that may have occurred in geocoding
                    }
                }
            }
        }