예제 #1
0
 public RoleController(IQuery query, IRoleQuery roleQuery, IRoleFacade roleFacade, IMenuQuery menuQuery)
 {
     this._query      = query;
     this._roleQuery  = roleQuery;
     this._roleFacade = roleFacade;
     this._menuQuery  = menuQuery;
 }
예제 #2
0
 public RoleAppService(IRoleQuery roleQuery, IRoleRepository roleRepository,
     IRoleFunctionRepository roleFunctionRepository)
 {
     _roleQuery = roleQuery;
     _roleRepository = roleRepository;
     _roleFunctionRepository = roleFunctionRepository;
 }
예제 #3
0
        /// <summary>
        /// Get the page to skip to within total, this will alter the offset
        /// stored in this class to 0 if the skip to target is > total. If you don't want
        /// the offset to alter pass null for total (or no arg) and it will just calculate the skip
        /// value.
        /// </summary>
        /// <remarks>
        /// This makes it easy to use with the common pattern for CollectionViews since you can
        /// just pass the query along after calling this function and it will have been
        /// altered as needed.
        /// </remarks>
        /// <param name="query">The query.</param>
        /// <param name="total">The total count of items in the collection to query or null for no check.</param>
        /// <returns></returns>
        public static int SkipTo(this IRoleQuery query, int?total = null)
        {
            var skipTo = query.Offset * query.Limit;

            if (total.HasValue && skipTo > total)
            {
                skipTo       = 0;
                query.Offset = 0;
            }
            return(skipTo);
        }
예제 #4
0
 public RoleService(IRoleQuery roleQuery, IRoleRepository roleRepository, IRoleValidator roleValidator)
 {
     _roleQuery      = roleQuery;
     _roleRepository = roleRepository;
     _roleValidator  = roleValidator;
 }
예제 #5
0
 /// <summary>
 /// Get all users in this repository.
 /// </summary>
 /// <returns></returns>
 public IQueryable <User> GetUsers(IRoleQuery query)
 {
     return(query.Create(authorizedUsersDb));
 }
예제 #6
0
 public RolesController(IRoleQuery roleQuery, IMediator mediator)
 {
     _roleQuery = roleQuery;
     _mediator  = mediator;
 }
예제 #7
0
 public RoleRepository(IRoleCommand roleCommand, IRoleQuery roleQuery)
 {
     _roleCommand = roleCommand;
     _roleQuery   = roleQuery;
 }
예제 #8
0
        public async Task <IActionResult> GetRoleAsync(Guid roleId, [FromServices] IRoleQuery query)
        {
            RoleResponse response = await query.RunAsync(roleId);

            return(response == null ? (IActionResult)NotFound() : Ok(response));
        }
예제 #9
0
        /// <summary>
        /// Get the users in the application.
        /// </summary>
        /// <typeparam name="TRoleAssignmentType">The type to map the user roles back onto.</typeparam>
        /// <param name="query">The query.</param>
        /// <returns>The role assignments for the specified users.</returns>
        public async Task <SystemUserRoleInfo <TRoleAssignmentType> > GetUsers <TRoleAssignmentType>(IRoleQuery query)
            where TRoleAssignmentType : IRoleAssignments, new()
        {
            var users = userRepo.GetUsers(query);
            var total = await users.CountAsync();

            users = users.Skip(query.SkipTo(total)).Take(query.Limit);

            var results = await users.ToListAsync();

            return(new SystemUserRoleInfo <TRoleAssignmentType>()
            {
                Total = total,
                Results = results.Select(i =>
                {
                    var e = GetUserRoles <TRoleAssignmentType>(i);
                    e.Wait();
                    return e.Result;
                }),
            });
        }