Ejemplo n.º 1
0
 public async Task GotoArticleDetailPage(Post posts)
 {
     await NavigationHelpers.GotoPageAsync(nameof(PostDetailPage),
                                           new Dictionary <string, object> {
         { "postParam", QueryStringHelpers.GetQueryParam(posts) }
     });
 }
        public void Parse_Object_HasMatchingString()
        {
            var testId1 = Guid.NewGuid();
            var testId2 = Guid.NewGuid();
            var testId3 = Guid.NewGuid();

            var time          = DateTime.Now;
            var formattedTime = time.ToUniversalTime().ToString("o");

            TestModel test = new TestModel
            {
                Id  = testId1,
                Ids = new List <Guid> {
                    testId2, testId3
                },
                Nested = new List <NestedTest> {
                    new  NestedTest {
                        Name = "testnest"
                    }
                },
                IsSomething = true,
                Time        = time
            };

            var expectedQueryString = $"?id={testId1}&ids={testId2}&ids={testId3}&name={test.Nested[0].Name}&isSomething=True&time={formattedTime}";
            var actualQueryString   = $"?{QueryStringHelpers.Parse(test)}";

            Assert.Equal(expectedQueryString, actualQueryString);
        }
Ejemplo n.º 3
0
 private async Task ViewCartCommandAsync()
 {
     if (Carts.Any())
     {
         await NavigationHelpers.GotoPageAsync(nameof(CartPage),
                                               new Dictionary <string, object> {
             { "cartsParam", QueryStringHelpers.GetQueryParam(Carts) }
         });
     }
 }
Ejemplo n.º 4
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.º 5
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.º 6
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.º 7
0
        public Task <MobfoxReport> GetReportAsync(MobfoxApplication application = null, DateTime?startDate = null, DateTime?endDate = null)
        {
            return(Task.Run(async() =>
            {
                var @params = new List <KeyValuePair <string, string> >();

                if (application != null)
                {
                    @params.Add(new KeyValuePair <string, string>(AppIdParameter, application.Id));
                }

                if (startDate != null)
                {
                    @params.Add(new KeyValuePair <string, string>(StartDateParameter, startDate.Value.ToString(DateFormat)));
                }

                if (endDate != null)
                {
                    @params.Add(new KeyValuePair <string, string>(EndDateParameter, endDate.Value.ToString(DateFormat)));
                }


                var uri = QueryStringHelpers.Build(@params, BuildAuthPathFor(PublisherReportMethod));

                //  Mobfox dont recognize parameters if they start with '?'...
                uri = uri.Replace('?', '&');
                try
                {
                    var report = (await GetMobfoxAsync <MobfoxReportResponse>(uri)).ReportInternal.Statistics;
                    report.StartTime = startDate.HasValue ? startDate.Value.Date : startDate;
                    report.EndTime = endDate.HasValue ? endDate.Value.Date : endDate;

                    return report;
                }
                catch (FormatException e)
                {
                    throw new MobfoxNoReportException(string.Empty, e);
                }
            }));
        }
Ejemplo n.º 8
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
                    }
                }
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 ///     Return the correctly formed and escaped query string that is can directly be added
 ///     to the Uri component, including the leading "?".
 /// </summary>
 /// <returns>Correct query string, with the leading "?"</returns>
 public override string ToString()
 {
     return(QueryStringHelpers.ConvertToUriString(this, prefixQuestionMark: true));
 }
Ejemplo n.º 10
0
 public LiaraQueryString(ILiaraContext context)
 {
     base.store = QueryStringHelpers.ParseFromString(context.Request.Info.Uri.Query);
 }