Beispiel #1
0
        public async Task <string> ExpertCount(string categoryId, string cityId, string distanceRadius, bool hasReviews, string lat, string lng)
        {
            var client  = new RestClient("https://api.iamnearby.net");
            var request = new RestRequest("/v1/catalog/experts/count", Method.POST);

            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("Device", device_info_prefs.GetString("device_json", String.Empty));
            if (userMethods.UserExists())
            {
                client.Authenticator = new HttpBasicAuthenticator(username: "", password: userMethods.GetUsersAuthToken());
            }
            request.AddHeader("deviceToken", device_info_prefs.GetString("firebase_token", String.Empty));
            if (String.IsNullOrEmpty(distanceRadius))
            {
                distanceRadius = "100000";
            }
            else if (distanceRadius == "0.5")
            {
                distanceRadius = "500";
            }
            else
            {
                distanceRadius = (Convert.ToInt32(distanceRadius) * 1000).ToString();
            }
            var filter_obj = new ExpertFilter
            {
                cityId         = cityId,
                distanceRadius = distanceRadius,
                hasReviews     = hasReviews
            };
            var coords_obj = new Coordinates
            {
                latitude  = lat.Replace(',', '.'),
                longitude = lng.Replace(',', '.')
            };
            var filterJson = JsonConvert.SerializeObject(filter_obj);

            request.AddJsonBody(new { categoryId = categoryId, filter = filter_obj, coordinates = coords_obj /*filterJson*/ });
            var response = await client.ExecuteTaskAsync(request);

            return(response.Content);
        }
Beispiel #2
0
        public async Task <string> ExpertsList(string categoryId, string lat, string lng, int sortType, string cityId, string distanceRadius, bool hasReviews, int offset = 0)
        {
            var client  = new RestClient("https://api.iamnearby.net");
            var request = new RestRequest("/v1/catalog/experts", Method.POST);

            if (userMethods.UserExists())
            {
                client.Authenticator = new HttpBasicAuthenticator(username: "", password: userMethods.GetUsersAuthToken());
            }
            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("Device", device_info_prefs.GetString("device_json", String.Empty));
            request.AddHeader("deviceToken", device_info_prefs.GetString("firebase_token", String.Empty));
            if (String.IsNullOrEmpty(distanceRadius))
            {
                distanceRadius = "100000";
            }
            else if (distanceRadius == "0.5")
            {
                distanceRadius = "500";
            }
            else
            {
                distanceRadius = (Convert.ToInt32(distanceRadius) * 1000).ToString();
            }
            var coords_obj = new Coordinates
            {
                latitude  = lat.Replace(',', '.'),
                longitude = lng.Replace(',', '.')
            };
            var filter_obj = new ExpertFilter
            {
                cityId         = cityId,//"176",
                distanceRadius = distanceRadius,
                hasReviews     = hasReviews
            };
            var center_obj = new CenterForMapFilter
            {
                latitude  = /*Convert.ToDouble(*/ lat /*, CultureInfo.InvariantCulture)*/,
                longitude = /*Convert.ToDouble(*/ lng/*, CultureInfo.InvariantCulture)*/
            };
            //Toast.MakeText(context, "объект координат создан", ToastLength.Short).Show();
            var map_filter_obj = new MapFilter
            {
                center         = center_obj,
                distanceRadius = Convert.ToInt32(distanceRadius)
            };

            request.AddJsonBody(
                new
            {
                categoryId  = categoryId,
                offset      = offset,
                count       = 100,
                mapFilter   = map_filter_obj,
                filter      = filter_obj,
                coordinates = coords_obj,
                sortType    = sortType
            });

            var response = await client.ExecuteTaskAsync(request);

            //Toast.MakeText(context, "запрос пройден", ToastLength.Short).Show();
            return(response.Content);
        }
        async public Task <IEnumerable <VExpert> > GetRandomExpertList([Required] int number, ExpertFilter filter)
        {
            var temp = filter.WhereNotInCompany;

            if (!string.IsNullOrEmpty(temp))
            {
                temp = string.Join(",", temp.Split(",").Select(i => $"'{i}'"));
                filter.WhereNotInCompany = temp;
            }

            var pagingResult = await Db.GetPagingListSpAsync <VExpert, ExpertFilter>(new Paging()
            {
                Index = 1,
                Size  = number
            },
                                                                                     filter,
                                                                                     orderStr : "NEWID()");

            return(pagingResult.List);
        }
 async public Task <PagingResult <VExpert> > GetPagingExpertList(Paging paging, ExpertFilter filter) =>
 await Db.GetPagingListSpAsync <VExpert, ExpertFilter>(paging, filter);