예제 #1
0
 public UserService(UserManager <TUser> userManager, IQueryableProvider <TUser> queryableProvider,
                    ILogger <UserService <TUser, TKey> > logger)
 {
     _userManager       = userManager;
     _queryableProvider = queryableProvider;
     _logger            = logger;
 }
예제 #2
0
        public UserStore(
            DataStore store,
            IPasswordHasher <TUser> passwordHasher,
            RoleManager <TRole> roles,
            IQueryableProvider <TUser> queryable,
            IIdentityClaimNameProvider claimNameProvider,
            ISuperUserInfoProvider superUserInfoProvider,
            ILookupNormalizer lookupNormalizer,
            IServiceProvider serviceProvider)
        {
            serviceProvider.TryGetRequestAbortCancellationToken(out var cancellationToken);
            serviceProvider.TryGetTenantId(out _tenantId);
            serviceProvider.TryGetTenantName(out _tenantName);
            serviceProvider.TryGetApplicationId(out _applicationId);
            serviceProvider.TryGetApplicationName(out _applicationName);

            CancellationToken = cancellationToken;

            _store          = store;
            _passwordHasher = passwordHasher;
            _roles          = roles;
            _queryable      = queryable;

            _claimNameProvider     = claimNameProvider;
            _superUserInfoProvider = superUserInfoProvider;
            _lookupNormalizer      = lookupNormalizer;
        }
        public static ICollection <ValidationResult> ExecuteValidation(this IQueryableProvider provider)
        {
            var errors  = new List <ValidationResult>();
            var entries = provider
                          .Context
                          .ChangeTracker
                          .Entries()
                          .Where(x => x.State == Microsoft.EntityFrameworkCore.EntityState.Added ||
                                 x.State == Microsoft.EntityFrameworkCore.EntityState.Modified)
                          .ToList();

            foreach (var entry in entries)
            {
                var entity             = entry.Entity;
                var validationProvider = new ValidationServiceProvider(provider);
                var validationContext  = new ValidationContext(entity, validationProvider, null);
                var entityErrors       = new List <ValidationResult>();
                if (!Validator.TryValidateObject(entity, validationContext, entityErrors))
                {
                    errors.AddRange(entityErrors);
                }
            }

            return(errors);
        }
예제 #4
0
 public OptionsBuilder(
     IQueryableProvider queryableProvider,
     IHttpContextAccessor httpContextAccessor)
 {
     _queryableProvider   = queryableProvider;
     _httpContextAccessor = httpContextAccessor;
 }
예제 #5
0
        public IQueryable <Badge> Execute(IQueryableProvider queryableProvider)
        {
            var baseQuery = queryableProvider.Query <Badge>();

            if (IncludeApp)
            {
                baseQuery = baseQuery.Include(i => i.App);
            }

            if (IncludeStage)
            {
                baseQuery = baseQuery.Include(i => i.Stage);
            }

            if (_id.HasValue)
            {
                baseQuery = baseQuery.Where(w => w.Id == _id);
            }

            if (_appId.HasValue)
            {
                baseQuery = baseQuery.Where(w => w.AppId == _appId && w.StageId == _stageId);
            }

            return(baseQuery.AsQueryable());
        }
예제 #6
0
 public ICollection <Option> GetOptions(IQueryableProvider provider)
 => provider
 .Context
 .Set <Manager>()
 .Select(x => new Option {
     Label = $"{x.FirstName} {x.LastName}", Value = x.Id
 })
 .ToList();
예제 #7
0
 public ICollection <Option> GetOptions(IQueryableProvider provider)
 => provider
 .Context
 .Set <State>()
 .Select(x => new Option {
     Label = x.Name, Value = x.Id
 })
 .ToList();
예제 #8
0
 public ICollection <Option> GetOptions(IQueryableProvider provider)
 => provider
 .Context
 .Set <Priority>()
 .Select(x => new Option {
     Label = x.PriorityType, Value = x.Id
 })
 .ToList();
예제 #9
0
 public RoleService(RoleManager <TRole> roleManager, ILookupNormalizer lookupNormalizer,
                    IRoleStoreExtended <TRole> roleStore, IQueryableProvider <TRole> queryableProvider)
 {
     _roleManager       = roleManager;
     _lookupNormalizer  = lookupNormalizer;
     _roleStore         = roleStore;
     _queryableProvider = queryableProvider;
 }
예제 #10
0
        public IQueryable <App> Execute(IQueryableProvider queryableProvider)
        {
            var baseQuery = queryableProvider
                            .Query <App>()
                            .Where(w => w.OrganisationId == _orgId)
                            .OrderBy(o => o.Name);

            return(baseQuery.AsQueryable());
        }
예제 #11
0
        public IQueryable <Stage> Execute(IQueryableProvider queryableProvider)
        {
            var baseQuery = queryableProvider
                            .Query <Stage>()
                            .Where(w => w.OrganisationId == _orgId)
                            .OrderBy(o => o.OrderBy); //defined sort order

            return(baseQuery.AsQueryable());
        }
        public IEnumerable <FormField> Handler(string context, string schema)
        {
            var properties = _modelLoader.LoadModel <FormAttribute>(context, schema);
            IQueryableProvider queryableProvider = _contextLoader.Load(context);

            var formFields = _formFieldsBuilder.BuildFormFieldsBySchemaProperty(properties, queryableProvider);

            return(formFields);
        }
예제 #13
0
 public TenantStore(
     DataStore store,
     IQueryableProvider <TTenant> queryable,
     IServiceProvider serviceProvider)
 {
     serviceProvider.TryGetRequestAbortCancellationToken(out var cancellationToken);
     CancellationToken = cancellationToken;
     _store            = store;
     _queryable        = queryable;
 }
예제 #14
0
 public TenantStore(
     IDataConnection connection,
     IQueryableProvider <TTenant> queryable,
     IServiceProvider serviceProvider)
 {
     serviceProvider.TryGetRequestAbortCancellationToken(out var cancellationToken);
     CancellationToken = cancellationToken;
     _connection       = connection;
     _queryable        = queryable;
 }
예제 #15
0
        public IQueryable <OrganisationKey> Execute(IQueryableProvider queryableProvider)
        {
            var baseQuery = queryableProvider.Query <OrganisationKey>()
                            .Where(w => w.Id == _id);

            if (_includeOrganisation)
            {
                baseQuery = baseQuery.Include(i => i.Organisation);
            }

            return(baseQuery.AsQueryable());
        }
예제 #16
0
 private void InitializeFormFieldBuilders(IQueryableProvider queryableProvider)
 {
     _factoryFormFields = new List <BuildFormField>
     {
         new CheckboxBuilder(),
         new DatePickerBuilder(),
         new DropDownListBuilder(new OptionsBuilder(queryableProvider, _httpContextAccessor)),
         new RadioBuilder(new OptionsBuilder(queryableProvider, _httpContextAccessor)),
         new InputBuilder(),
         new InputNumberBuilder()
     };
 }
        public static ICollection <ValidationResult> SaveChangesWithValidations(this IQueryableProvider provider)
        {
            var resultValidation = provider.ExecuteValidation();

            if (resultValidation.Any())
            {
                return(resultValidation);
            }

            provider.Context.SaveChanges();

            return(resultValidation);
        }
예제 #18
0
        public RoleStore(
            IQueryableProvider <TRole> queryable,
            DataStore store,
            IServiceProvider serviceProvider)
        {
            serviceProvider.TryGetRequestAbortCancellationToken(out var cancellationToken);
            serviceProvider.TryGetTenantId(out _tenantId);
            serviceProvider.TryGetApplicationId(out _applicationId);

            CancellationToken = cancellationToken;

            _queryable = queryable;
            _store     = store;
        }
예제 #19
0
        public IQueryable <App> Execute(IQueryableProvider queryableProvider)
        {
            var baseQuery = queryableProvider.Query <App>();

            if (_id.HasValue)
            {
                baseQuery = baseQuery.Where(w => w.Id == _id);
            }

            if (!string.IsNullOrWhiteSpace(_name))
            {
                baseQuery = baseQuery.Where(w => w.OrganisationId == _orgId && w.Name == _name);
            }

            return(baseQuery.AsQueryable());
        }
예제 #20
0
        public IQueryable <Organisation> Execute(IQueryableProvider queryableProvider)
        {
            DoValidations();

            var baseQuery = queryableProvider.Query <Organisation>();

            if (_id.HasValue)
            {
                baseQuery = baseQuery.Where(w => w.Id == _id);
            }

            if (!string.IsNullOrWhiteSpace(_name) & !string.IsNullOrWhiteSpace(_masterEmail))
            {
                baseQuery = baseQuery.Where(w => w.Name == _name && w.MasterEmail == _masterEmail);
            }

            return(baseQuery.AsQueryable());
        }
예제 #21
0
        public IQueryable <Member> Execute(IQueryableProvider queryableProvider)
        {
            //validate query data
            if (!_organisationId.HasValue && string.IsNullOrWhiteSpace(_email))
            {
                throw new ThisAppException(StatusCodes.Status417ExpectationFailed, Messages.Err417MissingObjectData("Member information"));
            }

            var baseQuery = queryableProvider.Query <Member>()
                            .Where(w => w.OrganisationId == _organisationId);

            if (!string.IsNullOrWhiteSpace(_email))
            {
                baseQuery = baseQuery.Where(w => w.Email == _email);
            }

            return(baseQuery.AsQueryable());
        }
        public IQueryable <Member> Execute(IQueryableProvider queryableProvider)
        {
            if (!_id.HasValue && !_orgId.HasValue)
            {
                throw new ThisAppException(StatusCodes.Status412PreconditionFailed, Messages.Err417MissingObjectData(""));
            }

            var baseQuery = queryableProvider.Query <Member>();

            if (_id.HasValue)
            {
                baseQuery = baseQuery.Where(w => w.Id == _id.Value);
            }

            if (_orgId.HasValue)
            {
                baseQuery = baseQuery.Where(w => w.OrganisationId == _orgId.Value && w.Email == _email);
            }

            return(baseQuery.AsQueryable());
        }
예제 #23
0
        public UserStore(IDataConnection connection,
                         IPasswordHasher <TUser> passwordHasher,
                         RoleManager <TRole> roles,
                         IQueryableProvider <TUser> queryable,
                         IOptions <IdentityOptionsExtended> identity,
                         IOptions <SecurityOptions> security,
                         IServiceProvider serviceProvider)
        {
            serviceProvider.TryGetRequestAbortCancellationToken(out var cancellationToken);
            serviceProvider.TryGetTenantId(out _tenantId);
            serviceProvider.TryGetTenantName(out _tenantName);

            CancellationToken = cancellationToken;

            _connection     = connection;
            _passwordHasher = passwordHasher;
            _roles          = roles;
            _queryable      = queryable;

            _identity = identity;
            _security = security;
        }
예제 #24
0
        public IEnumerable <FormField> BuildFormFieldsBySchemaProperty(
            IEnumerable <PropertyInfo> properties,
            IQueryableProvider queryableProvider)
        {
            var formFields = new List <FormField>();

            InitializeFormFieldBuilders(queryableProvider);
            foreach (var property in properties)
            {
                var formFieldConfig = _factoryFormFields.SingleOrDefault(x => x.CheckFormFieldType(property));
                if (formFieldConfig != null)
                {
                    formFields.Add(formFieldConfig.Build(property));
                }
                else
                {
                    formFields.Add(_defaultInputBuilder.Build(property));
                }
            }

            return(formFields);
        }
예제 #25
0
        public IQueryable <OrganisationKey> Execute(IQueryableProvider queryableProvider)
        {
            //validate query data
            if (!_organisationId.HasValue && _data == null)
            {
                throw new ThisAppException(StatusCodes.Status417ExpectationFailed, Messages.Err417MissingObjectData("Private Key information"));
            }

            var baseQuery = queryableProvider.Query <OrganisationKey>()
                            .Where(w => w.OrganisationId == _organisationId);

            if (_data != null)
            {
                baseQuery = baseQuery.Where
                            (
                    w =>
                    w.Description == _data.Description &&
                    w.ExpiryDate == _data.ExpiryDate &&
                    w.PrivateKey == _data.PrivateKey
                            );
            }

            return(baseQuery.AsQueryable());
        }
예제 #26
0
 public CastingBuilder(DbContext dbContext, IQueryableProvider queryableProvider, IMapper mapper)
 {
     _dbContext         = dbContext;
     _queryableProvider = queryableProvider;
     _mapper            = mapper;
 }
예제 #27
0
 public ListPersonQueryHandler(IQueryableProvider <Person> provider)
 {
     this.provider = provider;
 }
예제 #28
0
 public UserService(UserManager <TUser> userManager, IQueryableProvider <TUser> queryableProvider)
 {
     _userManager       = userManager;
     _queryableProvider = queryableProvider;
 }
예제 #29
0
 public TenantService(TenantManager <TTenant, TUser, TKey> tenantManager, IQueryableProvider <TTenant> queryableProvider)
 {
     _tenantManager     = tenantManager;
     _queryableProvider = queryableProvider;
 }
예제 #30
0
 public Runner(IActionHandler <Tin, TOut> actionHandler, IQueryableProvider provider)
 {
     _actionHandler = actionHandler;
     _provider      = provider;
 }