コード例 #1
0
 public ServiceDataWrapper <IList <ApplicationUserRequest> > GetAll([FromQuery] ApplicationUserFilter userFilter, [FromQuery] PaginationFilter pagination = null)
 {
     return(new ServiceDataWrapper <IList <ApplicationUserRequest> >
     {
         value = _service.GetApplicationUsersAsync(userFilter, pagination).Result
     });
 }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="queryable"></param>
        /// <returns></returns>
        private static IQueryable <ApplicationUser> AddFiltersOnQuery(ApplicationUserFilter filter, IQueryable <ApplicationUser> query)
        {
            /*
             * this filter is used to filter application user
             */
            query = (!string.IsNullOrEmpty(filter?.UserName)) ? query.Where(x => x.UserName.Contains(filter.UserName)) : query;

            /*
             *
             */
            query = (filter?.ExcludeAdmin == true) ? query.Where(x => x.UserRoles.Any(x => x.Role.Name != ApplicationConstant.ApplicationRoles.Administrator)): query;
            return(query);
        }
コード例 #3
0
        public async Task <IList <ApplicationUserRequest> > GetApplicationUsersAsync(ApplicationUserFilter userFilter, PaginationFilter paginationFilter)
        {
            var users = await _repository.GetApplicationUsersAsync(userFilter, paginationFilter);

            return(users.Select(x => new ApplicationUserRequest
            {
                Id = x.Id,
                UserName = x.UserName,
                Email = x.Email,
                ContactNo = x.ContactNo,
                Role = x.UserRoles.FirstOrDefault()?.Role?.Name,
                IsLocked = x.LockoutEnabled
            }).ToList());
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="roleName">Role Name</param>
        /// <param name="userFilter">User Filter</param>
        /// <param name="paginationFilter"></param>
        /// <returns></returns>
        public async Task <IList <ApplicationUser> > GetApplicationUsersAsync(ApplicationUserFilter userFilter, PaginationFilter paginationFilter)
        {
            var query = _context.Users.Include(u => u.UserRoles).ThenInclude(ur => ur.Role).AsQueryable();

            query = AddFiltersOnQuery(userFilter, query);

            if (paginationFilter == null)
            {
                return(await query.ToListAsync());
            }

            var skip = (paginationFilter.PageNumber - 1) * paginationFilter.PageSize;

            return(await query.Skip(skip).Take(paginationFilter.PageSize).ToListAsync());
        }