예제 #1
0
        /// <summary>
        /// Get FleetPools
        /// </summary>
        public FleetPoolResponse Get([FromUri] FleetPoolSearchRequest request)
        {
            if (request == null || !ModelState.IsValid)
            {
                throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
            }

            return(fleetPoolService.SerchFleetPool(request).CreateFrom());
        }
예제 #2
0
        /// <summary>
        /// Load All Fleet Pools
        /// </summary>
        public FleetPoolResponse SerchFleetPool(FleetPoolSearchRequest searchRequest)
        {
            int rowCount;

            return(new FleetPoolResponse
            {
                FleetPools = fleetPoolRepository.SearchFleetPool(searchRequest, out rowCount),
                TotalCount = rowCount
            });
        }
예제 #3
0
        /// <summary>
        /// SearchFleet Pool for the given parameters by user
        /// </summary>
        public IEnumerable <FleetPool> SearchFleetPool(FleetPoolSearchRequest request, out int rowCount)
        {
            int fromRow = (request.PageNo - 1) * request.PageSize;
            int toRow   = request.PageSize;

            Expression <Func <FleetPool, bool> > query =
                fleet =>
                (string.IsNullOrEmpty(request.FleetPoolSearchText) || fleet.FleetPoolCode.Contains(request.FleetPoolSearchText) || fleet.FleetPoolName.Contains(request.FleetPoolSearchText)) &&
                (!request.RegionId.HasValue || fleet.RegionId == request.RegionId.Value) &&
                (!request.OperationId.HasValue || fleet.OperationId == request.OperationId.Value);

            rowCount = DbSet.Count(query);

            return(request.IsAsc ? DbSet.Where(query).OrderBy(fleetPoolOrderByClause[request.FleetPoolOrderBy]).Skip(fromRow).Take(toRow).ToList() :
                   DbSet.Where(query).OrderByDescending(fleetPoolOrderByClause[request.FleetPoolOrderBy]).Skip(fromRow).Take(toRow).ToList());
        }