Ejemplo n.º 1
0
 /// <summary>
 /// Get Vehicle Statuses
 /// </summary>
 public VehicleStatusSearchRequestResponse Get([FromUri] VehicleStatusSearchRequest oppRequest)
 {
     if (oppRequest == null || !ModelState.IsValid)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
     }
     return(vehicleStatusService.SearchVehicleStatus(oppRequest).CreateFrom());
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Search Vehicle Status
        /// </summary>
        public VehicleStatusSearchRequestResponse SearchVehicleStatus(VehicleStatusSearchRequest request)
        {
            int rowCount;

            return(new VehicleStatusSearchRequestResponse
            {
                VehicleStatuses = vehicleStatusRepository.SearchVehicleStatus(request, out rowCount),
                TotalCount = rowCount
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// SearchD Vehicle Statuse
        /// </summary>
        public IEnumerable <VehicleStatus> SearchVehicleStatus(VehicleStatusSearchRequest request, out int rowCount)
        {
            int fromRow = (request.PageNo - 1) * request.PageSize;
            int toRow   = request.PageSize;
            Expression <Func <VehicleStatus, bool> > query =
                vehicleStatus =>
                (string.IsNullOrEmpty(request.VehicleStatusCodeNameFilterText) ||
                 (vehicleStatus.VehicleStatusCode.Contains(request.VehicleStatusCodeNameFilterText)) ||
                 (vehicleStatus.VehicleStatusName.Contains(request.VehicleStatusCodeNameFilterText)));

            rowCount = DbSet.Count(query);
            return(request.IsAsc
                ? DbSet.Where(query)
                   .OrderBy(vehicleStatusOrderByClause[request.VehicleStatusOrderBy])
                   .Skip(fromRow)
                   .Take(toRow)
                   .ToList()
                : DbSet.Where(query)
                   .OrderByDescending(vehicleStatusOrderByClause[request.VehicleStatusOrderBy])
                   .Skip(fromRow)
                   .Take(toRow)
                   .ToList());
        }