Exemplo n.º 1
0
        public async Task <ActionResult <PaginatedResponseModel <AppNavItemModel> > > GetAll(
            [FromQuery] AppNavItemSearchModel model
            )
        {
            try {
                var result = await repository.SearchAsync(model);

                return(result);
            }
            catch (Exception ex) {
                logger.LogError(ex, $"Can not search app_nav_items with {model.ToJson()}.");
                return(this.InternalServerError(ex));
            }
        }
Exemplo n.º 2
0
        public async Task <PaginatedResponseModel <AppNavItemModel> > SearchAsync(
            AppNavItemSearchModel model
            )
        {
            var query = Session.Query <AppNavItem>();
            // todo: add custom query here;
            var total = await query.LongCountAsync();

            var data = await query.OrderByDescending(e => e.Id)
                       .Skip(model.Skip).Take(model.Take)
                       .ToListAsync();

            return(new PaginatedResponseModel <AppNavItemModel> {
                Total = total,
                Data = Mapper.Map <IList <AppNavItemModel> >(data),
                Skip = model.Skip,
                Take = model.Take
            });
        }