示例#1
0
        // details for graph - num of recommendations in each city
        public JsonResult getGraphB()
        {
            List <getNumHotel> citys = new List <getNumHotel>();

            var result = (from h in db.hotels
                          join r in db.RecommendationsHotel on h.ID equals r.HotelID
                          group h by new { h.hotelCity }
                          into gr
                          select new
            {
                gr.Key.hotelCity,
                Amount = gr.Count()
            }
                          );

            foreach (var x in result)
            {
                getNumHotel sum = new getNumHotel();
                sum.State = x.hotelCity;
                sum.freq  = x.Amount;
                citys.Add(sum);
            }

            return(Json(citys, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        // details for graph - num of hotels in each city
        public JsonResult getGraphA()
        {
            List <getNumHotel> citys = new List <getNumHotel>();

            var result = (from du in db.hotels
                          group du by new { du.hotelCity }
                          into gr
                          select new
            {
                gr.Key.hotelCity,
                Amount = gr.Count()
            }
                          );

            foreach (var x in result)
            {
                getNumHotel sum = new getNumHotel();
                sum.State = x.hotelCity;
                sum.freq  = x.Amount;
                citys.Add(sum);
            }

            return(Json(citys, JsonRequestBehavior.AllowGet));
        }