Esempio n. 1
0
        //查询小区当前均价
        public int QueryNeighborhoodAvgPrice(NeighborhoodAvgPriceQueryConditions queryConditions, out List<View_NeighborhoodAvgPrice> result, out int totalPage)
        {
            using (var db = new HouseMarketEntities())
            {
                totalPage = 0;

                var entities = db.View_NeighborhoodAvgPrice;
                var query = SetQuery(entities, queryConditions, out totalPage);
                result = query.ToList();

                return 0;
            }
        }
        /// <summary>
        /// 查询平均价格
        /// </summary>
        /// <returns>城市均价或地区均价或小区均价,总页数</returns>
        public HttpResponseMessage Get()
        {
            int totalPage = 0;
            var queryString = Request.GetQueryNameValuePairs();

            if (queryString.FirstOrDefault(q => q.Key.ToLower() == "view").Key == null)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
            else if (queryString.First(q => q.Key.ToLower() == "view").Value.ToLower() == "city")
            {
                List<View_CityAvgPrice> result = new List<View_CityAvgPrice>();
                var queryConditions = new CityAvgPriceQueryConditions();
                queryConditions.GetValues(queryString);

                AvgPriceFunction avgPriceFunction = new AvgPriceFunction();
                avgPriceFunction.QueryCityAvgPrice(queryConditions, out result, out totalPage);

                List<object> objectResult = new List<object>() { result, new { totalPage = totalPage } };
                return Request.CreateResponse(HttpStatusCode.OK, objectResult);
            }
            else if (queryString.First(q => q.Key.ToLower() == "view").Value.ToLower() == "area")
            {
                List<View_AreaAvgPrice> result = new List<View_AreaAvgPrice>();
                var queryConditions = new AreaAvgPriceQueryConditions();
                queryConditions.GetValues(queryString);

                AvgPriceFunction avgPriceFunction = new AvgPriceFunction();
                avgPriceFunction.QueryAreaAvgPrice(queryConditions, out result, out totalPage);

                List<object> objectResult = new List<object>() { result, new { totalPage = totalPage } };
                return Request.CreateResponse(HttpStatusCode.OK, objectResult);
            }
            else if (queryString.First(q => q.Key.ToLower() == "view").Value.ToLower() == "neighborhood")
            {
                List<View_NeighborhoodAvgPrice> result = new List<View_NeighborhoodAvgPrice>();
                var queryConditions = new NeighborhoodAvgPriceQueryConditions();
                queryConditions.GetValues(queryString);

                AvgPriceFunction avgPriceFunction = new AvgPriceFunction();
                avgPriceFunction.QueryNeighborhoodAvgPrice(queryConditions, out result, out totalPage);

                List<object> objectResult = new List<object>() { result, new { totalPage = totalPage } };
                return Request.CreateResponse(HttpStatusCode.OK, objectResult);
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }