コード例 #1
0
        //查询区域当前均价
        public int QueryAreaAvgPrice(AreaAvgPriceQueryConditions queryConditions, out List<View_AreaAvgPrice> result, out int totalPage)
        {
            using (var db = new HouseMarketEntities())
            {
                totalPage = 0;

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

                return 0;
            }
        }
コード例 #2
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);
            }
        }