예제 #1
0
        // GET: api/FoodRecommend
        public async Task <object> Get(string UserID, string TagId = "")
        {
            string response = await Recommender.InvokeRequestResponseService(UserID);

            var        obj = JsonConvert.DeserializeObject <object>(response);
            JObject    rss = JObject.Parse(response);
            List <int> arr = new List <int>();

            for (int i = 1; i < 20; i++)
            {
                string tempstring = (string)rss["Results"]["output1"][0]["Item " + i.ToString()];
                if (!string.IsNullOrEmpty(tempstring))
                {
                    arr.Add(int.Parse(tempstring));
                }
            }

            ApplicationDbContext ApplicationDbContext = new ApplicationDbContext();
            var arr3 = ApplicationDbContext.FoodModels.Include("Restaurant")
                       .Where(c => arr.Contains(c.FoodID) && c.TagID.Contains(TagId))
                       .Select(x => new { x.Restaurant.Name, x.Restaurant.GPSLocation, x }).ToList();

            //var arr2 = ApplicationDbContext.FoodModels.Where(c => arr3.Contains(c.RestaurantID)).ToList();
            return(Json(arr2));
        }