Ejemplo n.º 1
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);
            }
        }
        //批量新增当前小区价格趋势
        public int AddCurrentNeighborhoodPriceTrends()
        {
            int totalPage = 0;
            int result = 0;
            List<View_NeighborhoodAvgPrice> currentNeighborhoodAvgPrices = new List<View_NeighborhoodAvgPrice>();
            List<NeighborhoodPriceTrend> currentNeighborhoodPriceTrends = new List<NeighborhoodPriceTrend>();

            AvgPriceFunction avgPriceFunction = new AvgPriceFunction();
            result = avgPriceFunction.QueryNeighborhoodAvgPrice(new NeighborhoodAvgPriceQueryConditions(), out currentNeighborhoodAvgPrices, out totalPage);
            if (result != 0)
            {
                return result;
            }

            PropertyFunction.CopyEntities(currentNeighborhoodAvgPrices, currentNeighborhoodPriceTrends);
            foreach (var trend in currentNeighborhoodPriceTrends)
            {
                trend.Date = int.Parse(DateTime.Now.ToString("yyyyMM"));
            }

            result = AddNeighborhoodPriceTrends(currentNeighborhoodPriceTrends);
            return result;
        }