Exemplo n.º 1
0
        public async Task <ApiResponse <IEnumerable <int> > > PutCategorySearchAsync(int IdService, int city_id, string keyword, [FromBody] Categories categories)
        {
            try
            {
                List <Restaurant> listR = new List <Restaurant>();
                _restaurantService.GetExternalServiceById(IdService);
                if (categories.categories == null)
                {
                    return(ApiUtil <IEnumerable <int> > .CreateSuccessfulResult(
                               new int[] {}
                               ));
                }
                if (categories.categories.Count() < 1)
                {
                    listR = await _restaurantService.GetRestaurantsByKeywordAsync(city_id, keyword);
                }
                List <RestaurantCategory>          newList = new List <RestaurantCategory>();
                JsonDtoMapper <RestaurantCategory> map     = new JsonDtoMapper <RestaurantCategory>();
                foreach (var category in categories.categories)//get the fisrt catalogue
                {
                    newList.Add(map.ToDto(category));
                }
                listR = await _restaurantService.GetRestaurantsByCategoriesKeywordAsync(city_id, newList, keyword);

                return(ApiUtil <IEnumerable <int> > .CreateSuccessfulResult(
                           listR.Select(l => Int32.Parse(l.restaurant_id))
                           ));
            }
            catch (Exception e)
            {
                return(ApiUtil <IEnumerable <int> > .CreateFailResult(e.ToString()));
            }
        }
Exemplo n.º 2
0
        public static List <RestaurantCategory> ConvertString2ListRestaurantCategories(string result)
        {
            dynamic data = JObject.Parse(result);
            List <RestaurantCategory>          newList = new List <RestaurantCategory>();
            JsonDtoMapper <RestaurantCategory> map     = new JsonDtoMapper <RestaurantCategory>();

            foreach (var categories in data.reply.country.now_services[0].categories)
            {
                newList.Add(map.ToDto(categories));
            }
            return(newList);
        }
Exemplo n.º 3
0
        public static List <Province> ConvertString2ListProvinces(string result)
        {
            dynamic                  data    = JObject.Parse(result);
            List <Province>          newList = new List <Province>();
            JsonDtoMapper <Province> map     = new JsonDtoMapper <Province>();

            foreach (var province in data.reply.metadata.province)
            {
                newList.Add(map.ToDto(province));
            }
            return(newList);
        }
Exemplo n.º 4
0
        public static List <FoodCategory> ConvertString2ListFoodCatalogue(string result)
        {
            dynamic                      data    = JObject.Parse(result);
            List <FoodCategory>          newList = new List <FoodCategory>();
            JsonDtoMapper <FoodCategory> map     = new JsonDtoMapper <FoodCategory>();

            foreach (var dish in data.reply.menu_infos)
            {
                newList.Add(map.ToDto(dish));
            }
            return(newList);
        }
Exemplo n.º 5
0
        public static DeliveryDetail ConvertString2DeliveryInfos(string result)
        {
            dynamic data = JObject.Parse(result);
            JsonDtoMapper <DeliveryDetail> map = new JsonDtoMapper <DeliveryDetail>();
            DeliveryDetail deliveryInfos       = new DeliveryDetail();

            if (data.result == "success")
            {
                deliveryInfos = map.ToDto(data.reply.delivery_detail);
            }
            return(deliveryInfos);
        }
Exemplo n.º 6
0
        public static List <DeliveryInfos> ConvertString2ListDeliveryInfos(string result)
        {
            dynamic data = JObject.Parse(result);
            List <DeliveryInfos>          newList = new List <DeliveryInfos>();
            JsonDtoMapper <DeliveryInfos> map     = new JsonDtoMapper <DeliveryInfos>();

            if (data.result == "success")
            {
                foreach (var delivery in data.reply.delivery_infos)
                {
                    newList.Add(map.ToDto(delivery));
                }
            }
            return(newList);
        }