public async Task <IActionResult> Filter([FromQuery] PaginationParams param, FilterRackLocationParam filterParam) { var result = await _service.Filter(param, filterParam); Response.AddPagination(result.CurrentPage, result.PageSize, result.TotalCount, result.TotalPages); return(Ok(result)); }
public async Task <PagedList <RackLocation_Main_Dto> > Filter(PaginationParams param, FilterRackLocationParam filterParam) { var pred_Rack_Location = PredicateBuilder.New <WMSB_RackLocation_Main>(true); if (!String.IsNullOrEmpty(filterParam.Factory)) { pred_Rack_Location.And(x => x.Factory_ID == filterParam.Factory); } if (!String.IsNullOrEmpty(filterParam.Wh)) { pred_Rack_Location.And(x => x.WH_ID == filterParam.Wh); } if (!String.IsNullOrEmpty(filterParam.Building)) { pred_Rack_Location.And(x => x.Build_ID == filterParam.Building); } if (!String.IsNullOrEmpty(filterParam.Floor)) { pred_Rack_Location.And(x => x.Floor_ID == filterParam.Floor); } if (!String.IsNullOrEmpty(filterParam.Area)) { pred_Rack_Location.And(x => x.Area_ID == filterParam.Area); } var resultAll = _repoRackLocation.FindAll(pred_Rack_Location).ProjectTo <RackLocation_Main_Dto>(_configMapper); resultAll = resultAll.OrderByDescending(x => x.Updated_Time).Select(x => new RackLocation_Main_Dto { BuildingName = _repoCode.GetBuildingName(x.Build_ID), AreaName = _repoCode.GetAreaName(x.Area_ID), FloorName = _repoCode.GetFloorName(x.Floor_ID), ID = x.ID, Rack_Location = x.Rack_Location, Rack_Code = x.Rack_Code, Rack_Level = x.Rack_Level, Rack_Bin = x.Rack_Bin, Factory_ID = x.Factory_ID, WH_ID = x.WH_ID, Build_ID = x.Build_ID, Floor_ID = x.Floor_ID, Area_ID = x.Area_ID, CBM = x.CBM, Max_per = x.Max_per, Memo = x.Memo, Rack_Invalid_date = x.Rack_Invalid_date, Updated_Time = x.Updated_Time, Updated_By = x.Updated_By, }); return(await PagedList <RackLocation_Main_Dto> .CreateAsync(resultAll, param.PageNumber, param.PageSize)); }