示例#1
0
 public HandicapResponse(IQueryable <T> query, HandicapError error, int cursor, int pageSize)
 {
     TotalCount  = query.Count();
     Cursor      = cursor;
     PageSize    = pageSize;
     HasNext     = ((Cursor * PageSize) + PageSize) < TotalCount;
     HasPrevious = (Cursor * PageSize) < 0;
     Error       = error;
     Payload     = query.Skip(Cursor * PageSize).Take(PageSize).ToList <T>();
 }
示例#2
0
 public static HandicapResponse <T, S> CreateErrorResponse(HandicapError error)
 {
     return(new HandicapResponse <T, S>
     {
         Cursor = 0,
         Error = error,
         HasNext = false,
         HasPrevious = false,
         PageSize = 0,
         Payload = null,
         TotalCount = 0
     });
 }
示例#3
0
        public static HandicapResponse <T, S> Create(IQueryable <S> query, HandicapError error, int cursor, int pageSize, IMapper mapper)
        {
            var response     = new HandicapResponse <T, S>();
            var list         = query.Skip(cursor * pageSize).Take(pageSize).ToList();
            var responseList = mapper.Map <List <T> >(list);
            var totalCount   = query.Count();

            response.TotalCount  = totalCount;
            response.Cursor      = cursor;
            response.PageSize    = pageSize;
            response.HasNext     = ((cursor * pageSize) + pageSize) < totalCount;
            response.HasPrevious = (cursor * pageSize) < 0;
            response.Error       = error;
            response.Payload     = responseList;

            return(response);
        }