Пример #1
0
        public ActionResult Get([FromQuery] QueryParameter parameter)
        {
            SavedBuildingAttService savedBuildingAttService = new SavedBuildingAttService();
            SavedAttrController     savedAttrController     = new SavedAttrController(savedBuildingAttService);
            var strings = savedAttrController.GetAttribute();//获取到的属性值

            List <Dictionary <string, string> > listDic = new List <Dictionary <string, string> >();
            List <Attributes> listAtt = new List <Attributes>();
            var buildings             = _estateStaService.GetBuildings(parameter);

            foreach (var item in buildings)
            {
                Dictionary <string, string> dic = new Dictionary <string, string>();
                foreach (var item1 in strings)
                {
                    if (item1.isShow)
                    {
                        var value = item.GetValue(item1.name);
                        dic.Add(item1.cname, value);
                    }
                }

                listDic.Add(dic);
            }

            // var properties=type.GetProperties();
            //var query1=from building in buildings select (building.AppLandArea,building.AreaBuilding);
            //var query2=query1.ToList();
            // var buildingResource = _mapper.Map<List<BuildingResource>>(buildings);


            // Type t = ClassHelper.BuildType("MyClass");
            // var propertys= type.GetProperties();
            //Type newType = typeof(DynamicUpdateAtt);
            //var property= newType.GetProperties();
            // var returnRes = _mapper.Map<DynamicUpdateAtt> (buildings);
            var preLink  = buildings.HasPrevious ? CreateBuildingUri(parameter, PaginationResourceUriType_uriType.pagePre) : null;
            var nextLink = buildings.HasNext ? CreateBuildingUri(parameter, PaginationResourceUriType_uriType.pageNext) : null;
            var mate     = new
            {
                buildings.TotalItemsCount,
                buildings.PaginationBase.PageSize,
                buildings.PaginationBase.PageIndex,
                buildings.PageCount,
                PreviousPageLink = preLink,
                NextPageLink     = nextLink
            };

            Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(mate));

            return(Ok(listDic));
        }
 public SavedAttrController(SavedBuildingAttService savedBuildingAttService)
 {
     _savedBuildingAttService = savedBuildingAttService;
 }