public async Task <ActionResult <PaginatedResponseModel <AppPrivilegeModel> > > GetAll(
        [FromQuery] AppPrivilegeSearchModel model
        )
    {
        try {
            var result = await repository.SearchAsync(model);

            return(result);
        }
        catch (Exception ex) {
            logger.LogError(ex, $"Can not search app_privileges with {model.ToJson()} .");
            return(this.InternalServerError(ex));
        }
    }
Esempio n. 2
0
        public async Task <PaginatedResponseModel <AppPrivilegeModel> > SearchAsync(
            AppPrivilegeSearchModel model
            )
        {
            var query = Session.Query <AppPrivilege>();

            if (!string.IsNullOrEmpty(model.Module))
            {
                query = query.Where(p => p.Module == model.Module);
            }
            var total = await query.LongCountAsync();

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

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