예제 #1
0
 /// <summary>
 /// Get vehicle Makes
 /// </summary>
 public VehicleMakeSearchRequestResponse Get([FromUri] VehicleMakeSearchRequest request)
 {
     if (request == null || !ModelState.IsValid)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
     }
     return(vehicleMakeService.SearchVehicleMake(request).CreateFromm());
 }
예제 #2
0
        /// <summary>
        /// Search Vehicle Make
        /// </summary>
        public VehicleMakeSearchRequestResponse SearchVehicleMake(VehicleMakeSearchRequest request)
        {
            int rowCount;

            return(new VehicleMakeSearchRequestResponse
            {
                VehicleMakes = vehicleMakeRepository.SearchVehicleMake(request, out rowCount),
                TotalCount = rowCount
            });
        }
예제 #3
0
        /// <summary>
        /// Search Vehicle Make
        /// </summary>
        public IEnumerable <VehicleMake> SearchVehicleMake(VehicleMakeSearchRequest request, out int rowCount)
        {
            int fromRow = (request.PageNo - 1) * request.PageSize;
            int toRow   = request.PageSize;
            Expression <Func <VehicleMake, bool> > query =
                vehicleMake =>
                (string.IsNullOrEmpty(request.VehicleMakeCodeNameText) || (vehicleMake.VehicleMakeCode.Contains(request.VehicleMakeCodeNameText)) ||
                 (vehicleMake.VehicleMakeName.Contains(request.VehicleMakeCodeNameText)));

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