// Gets vehicles.
 // <param name="paging">Paging.</param>
 // <param name="filterVehicle">Filter vehicle.</param>
 // <param name="sorting">Sorting.</param>
 // <returns>Vehicles.</returns>
 public async Task <IEnumerable <IVehicleModel> > GetVehiclesAsync(IPagingParameters paging, IVehicleFilter filterVehicle, ISortingParameters sorting)
 {
     return(await vehicleRepository.GetVehiclesAsync(paging, filterVehicle, sorting));
 }
        /// <summary>
        /// Gets vehicles.
        /// </summary>
        /// <param name="paging">Paging.</param>
        /// <param name="filterVehicle">Filter vehicle.</param>
        /// <param name="sorting">Sorting.</param>
        /// <returns>Vehicles.</returns>
        public async Task <IEnumerable <IVehicleModel> > GetVehiclesAsync(IPagingParameters paging, IVehicleFilter filterVehicle, ISortingParameters sorting)
        {
            var listOfVehicles = await vehicleContext.VehicleModels.ToListAsync();

            var filteredListOfVehicles = listOfVehicles
                                         .Where(item => filterVehicle.CategoryId.HasValue ? item.VehicleCategoryId == filterVehicle.CategoryId : item != null)
                                         .Where(item => String.IsNullOrEmpty(filterVehicle.FindVehicle) ? item != null : item.Name.Contains(filterVehicle.FindVehicle))
                                         .Where(item => filterVehicle.MakerId == Guid.Empty ? item != null : item.VehicleMakerId == filterVehicle.MakerId);

            var sortedList          = filteredListOfVehicles.OrderBy(sorting.SortField + " " + sorting.SortOrder);
            var mappedList          = mapper.Map <List <VehicleModelPoco> >(sortedList);
            var pagedList           = mappedList.ToPagedList(paging.PageNumber, paging.PageSize);
            var pagedListOfVehicles = new StaticPagedList <VehicleModelPoco>(pagedList, pagedList.GetMetaData());

            return(pagedListOfVehicles);
        }