private Result <List <AppGroup> > GetMatchingUserGroups(
            IAppGroupRepository groupRepo,
            string[] groupNames
            )
        {
            if (groupRepo == null)
            {
                return(Result.Fail <List <AppGroup> >("AppGroup repo is not specified"));
            }

            if (groupNames == null)
            {
                return(Result.Fail <List <AppGroup> >("No user groups are specified"));
            }

            groupNames = groupNames.Select(d => d.Trim().ToUpper()).Distinct().ToArray();

            List <AppGroup> appGroups = groupRepo.GetList().ToList();
            List <AppGroup> result    = new List <AppGroup>();

            foreach (var name in groupNames)
            {
                Maybe <AppGroup> appgroup = appGroups.FirstOrDefault(d => d.Name.ToUpper() == name);
                if (appgroup.HasNoValue)
                {
                    return(Result.Fail <List <AppGroup> >($"No matching user group found: {name}"));
                }

                result.Add(appgroup.Value);
            }

            return(Result.Ok(result));
        }
Esempio n. 2
0
 public AppGroupService(IUnitOfWork unitOfWork,
                        IAppUserGroupRepository appUserGroupRepository,
                        IAppGroupRepository appGroupRepository)
 {
     this._appGroupRepository     = appGroupRepository;
     this._appUserGroupRepository = appUserGroupRepository;
     this._unitOfWork             = unitOfWork;
 }
Esempio n. 3
0
 public AppGroupService(IUnitOfWork unitOfWork
                        , IAppGroupRepository appGroupRepo
                        , IAppUserGroupRepository appUserGroupRepository) : base(unitOfWork, appGroupRepo)
 {
     _appGroupRepo           = appGroupRepo;
     _appUserGroupRepository = appUserGroupRepository;
     _uow = unitOfWork;
 }
 public UserGroupController(
     ILogger <UserGroupController> logger,
     UnitOfWork unitOfWork,
     ICurrentUser currentUser)
     : base(unitOfWork, logger)
 {
     _logger         = logger;
     _groupRepo      = new AppGroupRepository(unitOfWork);
     _permissionRepo = new AppPermissionRepository(unitOfWork);
     _currentUser    = currentUser;
 }
        public AccountController(
            ILogger <AccountController> logger,
            IOptions <AuthSettings> authSettings,
            UnitOfWork unitOfWork,
            IJwtTokenValidator jwtTokenValidator,
            IJwtFactory jwtFactory,
            ITokenFactory tokenFactory,
            ICurrentUser currentUser)
            : base(unitOfWork, logger)
        {
            _logger       = logger;
            _authSettings = authSettings.Value;

            _jwtFactory        = jwtFactory;
            _tokenFactory      = tokenFactory;
            _jwtTokenValidator = jwtTokenValidator;
            _currentUser       = currentUser;

            _appUserRepo = new AppUserRepository(unitOfWork);
            _groupRepo   = new AppGroupRepository(unitOfWork);
        }
Esempio n. 6
0
 public AppGroupsController(IAppGroupRepository ir) => repo = ir;