SHARE
TWEET

Untitled

a guest Jul 16th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [HttpGet]
  2. public async Task<IEnumerable<TripListViewModel>> GetTrips([FromQuery]TripsPaginationFilterViewModel model)
  3. {
  4.     var trips = await _viagemRepository.GetList(model.Page, model.Limit);
  5.  
  6.     return _mapper.Map<IEnumerable<TripListViewModel>>(trips);
  7. }
  8.  
  9. public class TripsPaginationFilterViewModel : PaginationFilterViewModel
  10. {
  11.    public DateTime DateStart { get; set; }
  12.    public DateTime DateFinish { get; set; }
  13.    public Guid TrechoId { get; set; }
  14. }
  15.  
  16. public class PaginationFilterViewModel
  17. {
  18.    public int Page { get; set; } = 1;
  19.    public int Limit { get; set; } = 20;
  20.    public bool IncludeInactivs { get; set; } = false;
  21. }
  22.  
  23. public async Task<List<TEntity>> GetList(int page, int limit, Expression<Func<TEntity, bool>> predicate)
  24. {
  25.     if (predicate!= null)
  26.     {
  27.         return await DbSet.AsNoTracking().Where(predicate).Skip((page - 1) * limit).Take(limit).ToListAsync();
  28.     }
  29.  
  30.     return await DbSet.AsNoTracking().Skip((page - 1) * limit).Take(limit).ToListAsync();
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top