예제 #1
0
파일: NowService.cs 프로젝트: lnmthuc/fos
        public async Task <List <DeliveryInfos> > GetRestaurantsDeliveryInforAsync(List <Restaurant> restaurant)
        {
            //Get function
            APIDetail api = apisJson.GetRestaurantDeliveryInfor;
            //Set Fields
            StringBuilder rid = new StringBuilder();

            foreach (var r in restaurant)
            {
                rid.Append("," + r.restaurant_id);
            }
            if (restaurant.Count() != 0)
            {
                rid.Remove(0, 1);                         // remove the first comma
            }
            api.AvailableBodys.Where(a => a.FieldName == "restaurant_ids").FirstOrDefault().ValueDefault
                = "[" + rid + "]";// 217 is id of HCM city
            //Call API
            RequestMethodFactory method = new RequestMethodFactory(api);
            var response = await method.CallApiAsync();

            var result = response.Content.ReadAsStringAsync().Result;

            return(ConvertJson.ConvertString2ListDeliveryInfos(result));
        }
예제 #2
0
파일: NowService.cs 프로젝트: lnmthuc/fos
        public async Task <List <Restaurant> > GetRestaurantsAsync(Province province, string keyword, List <RestaurantCategory> category)
        {
            //Get function
            APIDetail api = apisJson.SearchRestaurantsInProvince;

            //Set Fields
            api.AvailableBodys.Where(a => a.FieldName == "city_id").FirstOrDefault().ValueDefault
                = province.id.ToString();// 217 is id of HCM city
            api.AvailableBodys.Where(a => a.FieldName == "keyword").FirstOrDefault().ValueDefault
                = "" + keyword + "";
            if (category != null)
            {
                StringBuilder icate = new StringBuilder();
                foreach (var c in category)
                {
                    icate.Append(",{\"code\":" + c.code + ",\"id\":" + c.id + "}");
                }
                if (category.Count() != 0)
                {
                    icate.Remove(0, 1);                       // remove the first comma
                }
                api.AvailableBodys.Where(a => a.FieldName == "combine_categories").FirstOrDefault().ValueDefault
                    = "[" + icate + "]";
            }

            //Call API
            RequestMethodFactory method = new RequestMethodFactory(api);
            var response = await method.CallApiAsync();

            var result = response.Content.ReadAsStringAsync().Result;

            return(ConvertJson.ConvertString2ListRestaurant(result));
        }
예제 #3
0
파일: NowService.cs 프로젝트: lnmthuc/fos
        public async Task <List <RestaurantCategory> > GetMetadataForCategoryAsync()
        {
            //Get function
            APIDetail api = apisJson.GetMetadataForCategory;
            //Call API
            RequestMethodFactory method = new RequestMethodFactory(api);
            var response = await method.CallApiAsync();

            var result = response.Content.ReadAsStringAsync().Result;

            return(ConvertJson.ConvertString2ListRestaurantCategories(result));
        }
예제 #4
0
파일: NowService.cs 프로젝트: lnmthuc/fos
        public async Task <string> GetDeliveryFromUrlAsync(Province province, DeliveryInfos delivery)
        {
            //Get function
            APIDetail api = apisJson.GetDeliveryFromUrl;

            //Set Fields
            api.AvailableParams.Where(a => a.FieldName == "url").FirstOrDefault().ValueDefault
                = province.name_url + "/" + delivery.url_rewrite_name;
            //Call API
            RequestMethodFactory method = new RequestMethodFactory(api);
            var response = await method.CallApiAsync();

            return(response.Content.ReadAsStringAsync().Result);
        }
예제 #5
0
파일: NowService.cs 프로젝트: lnmthuc/fos
        public async Task <List <FoodCategory> > GetFoodCataloguesAsync(DeliveryInfos delivery)
        {
            //Get function
            APIDetail api = apisJson.GetDeliveryDishes;

            //Set Fields
            api.AvailableParams.Where(a => a.FieldName == "request_id").FirstOrDefault().ValueDefault
                = delivery.delivery_id.ToString();
            //Call API
            RequestMethodFactory method = new RequestMethodFactory(api);
            var response = await method.CallApiAsync();

            var result = response.Content.ReadAsStringAsync().Result;

            return(ConvertJson.ConvertString2ListFoodCatalogue(result));
        }
예제 #6
0
파일: NowService.cs 프로젝트: lnmthuc/fos
        public async Task <DeliveryDetail> GetRestaurantDetailAsync(Restaurant restaurant)
        {
            //Get function
            APIDetail api = apisJson.GetRestaurantDetail;

            //Set Fields
            api.AvailableParams.Where(a => a.FieldName == "request_id").FirstOrDefault().ValueDefault
                = restaurant.delivery_id.ToString();
            //Call API
            RequestMethodFactory method = new RequestMethodFactory(api);
            var response = await method.CallApiAsync();

            var result = response.Content.ReadAsStringAsync().Result;

            return(ConvertJson.ConvertString2DeliveryInfos(result));
        }
예제 #7
0
파일: NowService.cs 프로젝트: lnmthuc/fos
        public async Task <List <DeliveryInfos> > GetRestaurantDeliveryInforAsync(Restaurant restaurant)
        {
            //Get function
            APIDetail api = apisJson.GetRestaurantDeliveryInfor;

            //Set Fields
            api.AvailableBodys.Where(a => a.FieldName == "restaurant_ids").FirstOrDefault().ValueDefault
                = "[" + restaurant.restaurant_id.ToString() + "]";// 217 is id of HCM city
            //Call API
            RequestMethodFactory method = new RequestMethodFactory(api);
            var response = await method.CallApiAsync();

            var result = response.Content.ReadAsStringAsync().Result;

            return(ConvertJson.ConvertString2ListDeliveryInfos(result));
        }