示例#1
0
        private static async Task InitRole(
            TestUserAreaInfo testUserAreaInfo,
            CofoundryDbContext dbContext,
            IAdvancedContentRepository contentRepository,
            TestRoleInfo role
            )
        {
            role.RoleId = await dbContext
                          .Roles
                          .FilterByRoleCode(role.RoleCode)
                          .Select(c => c.RoleId)
                          .SingleAsync();

            var uniqueIdentifier = testUserAreaInfo.UserAreaCode + role.RoleId;

            role.User = new TestUserInfo()
            {
                Username = uniqueIdentifier.ToLower() + "@example.com",
                Password = uniqueIdentifier + "w1P1r4Rz"
            };

            role.User.UserId = await contentRepository
                               .Users()
                               .AddAsync(new AddUserCommand()
            {
                Email        = role.User.Username,
                FirstName    = "Role",
                LastName     = "User",
                Password     = role.User.Password,
                RoleId       = role.RoleId,
                UserAreaCode = testUserAreaInfo.UserAreaCode
            });
        }
示例#2
0
 public RegisterMemberAndLogInCommandHandler(
     IAdvancedContentRepository contentRepository,
     IMailService mailService
     )
 {
     _contentRepository = contentRepository;
     _mailService       = mailService;
 }
示例#3
0
 public UserAreasApiController(
     IAdvancedContentRepository contentRepository,
     IApiResponseHelper apiResponseHelper
     )
 {
     _contentRepository = contentRepository;
     _apiResponseHelper = apiResponseHelper;
 }
示例#4
0
 public TestController(
     IAdvancedContentRepository contentRepository,
     IDomainRepository domainRepository
     )
 {
     _contentRepository = contentRepository;
     _domainRepository = domainRepository;
 }
示例#5
0
 private async Task InitUserAreaAsync(
     TestUserAreaInfo testUserAreaInfo,
     CofoundryDbContext dbContext,
     IAdvancedContentRepository contentRepository
     )
 {
     await InitRole(testUserAreaInfo, dbContext, contentRepository, testUserAreaInfo.RoleA);
     await InitRole(testUserAreaInfo, dbContext, contentRepository, testUserAreaInfo.RoleB);
 }
 public UsersController(
     IUserSessionService userSessionService,
     CofoundryDbContext cofoundryDbContext,
     IAdvancedContentRepository contentRepository
     )
 {
     _userSessionService = userSessionService;
     _cofoundryDbContext = cofoundryDbContext;
     _contentRepository  = contentRepository;
 }
示例#7
0
 public UpdateBookingCommandHandler(
     IAdvancedContentRepository domainRepository,
     IBookingProvider bookingProvider,
     IPermissionValidationService permissionValidationService,
     ITenantCategoryProvider tenantCategoryProvider)
 {
     DomainRepository            = domainRepository;
     BookingProvider             = bookingProvider;
     PermissionValidationService = permissionValidationService;
     TenantCategoryProvider      = tenantCategoryProvider;
 }
 public SendWelcomeLetterCommandHandler(
     IAdvancedContentRepository domainRepository,
     IBookingProvider bookingProvider,
     IPermissionValidationService permissionValidationService,
     ICurrentUserProvider currentUserProvider)
 {
     DomainRepository            = domainRepository;
     BookingProvider             = bookingProvider;
     PermissionValidationService = permissionValidationService;
     CurrentUserProvider         = currentUserProvider;
 }
示例#9
0
 public ImportBookingsCommandHandler(
     IAdvancedContentRepository domainRepository,
     ITenantCategoryProvider tenantCategoryProvider,
     IPermissionValidationService permissionValidationService,
     BookingSettings bookingSettings)
 {
     DomainRepository            = domainRepository;
     TenantCategoryProvider      = tenantCategoryProvider;
     PermissionValidationService = permissionValidationService;
     BookingSettings             = bookingSettings;
 }
示例#10
0
 public AnonymizeBookingsCommandHandler(
     IBookingProvider bookingProvider,
     IAdvancedContentRepository domainRepository,
     ICommandExecutor executor,
     IPermissionValidationService permissionValidationService)
 {
     BookingProvider             = bookingProvider;
     DomainRepository            = domainRepository;
     CommandExecutor             = executor;
     PermissionValidationService = permissionValidationService;
 }
示例#11
0
 public DeleteBookingCommandHandler(
     IAdvancedContentRepository domainRepository,
     ICommandExecutor commandExecutor,
     IBookingProvider bookingProvider,
     IPermissionValidationService permissionValidationService)
 {
     DomainRepository            = domainRepository;
     CommandExecutor             = commandExecutor;
     BookingProvider             = bookingProvider;
     PermissionValidationService = permissionValidationService;
 }
示例#12
0
 public AuthController(
     IAdvancedContentRepository contentRepository,
     IAuthorizedTaskTokenUrlHelper authorizedTaskTokenUrlHelper,
     IAdminRouteLibrary adminRouteLibrary,
     AdminSettings adminSettings
     )
 {
     _contentRepository            = contentRepository.WithContext <CofoundryAdminUserArea>();
     _authorizedTaskTokenUrlHelper = authorizedTaskTokenUrlHelper;
     _adminRouteLibrary            = adminRouteLibrary;
     _adminSettings = adminSettings;
 }
示例#13
0
 public BookingProvider(
     IAdvancedContentRepository contentRepository,
     IPermissionValidationService permissionValidationService,
     ITenantCategoryProvider tenantCategoryProvider,
     IContentRouteLibrary contentRouteLibrary,
     BookingSettings bookingSettings)
     : base(contentRepository)
 {
     PermissionValidationService = permissionValidationService;
     TenantCategoryProvider      = tenantCategoryProvider;
     ContentRouteLibrary         = contentRouteLibrary;
     BookingSettings             = bookingSettings;
 }
示例#14
0
 private static async Task AddCustomEntity(TestCustomEntityInfo customEntity, IAdvancedContentRepository contentRepository)
 {
     customEntity.CustomEntityId = await contentRepository
                                   .CustomEntities()
                                   .AddAsync(new AddCustomEntityCommand()
     {
         CustomEntityDefinitionCode = customEntity.CustomEntityDefinitionCode,
         Model   = new TestCustomEntityDataModel(),
         Publish = true,
         Title   = customEntity.Title,
         UrlSlug = customEntity.UrlSlug
     });
 }
示例#15
0
        /// <summary>
        /// Sets the execution context for any queries or commands
        /// chained of this instance. Typically used to impersonate
        /// a user, elevate permissions or maintain context in nested
        /// query or command execution.
        /// </summary>
        /// <param name="executionContext">
        /// The execution context instance to use.
        /// </param>
        public static IAdvancedContentRepository WithExecutionContext(this IAdvancedContentRepository contentRepository, IExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException(nameof(executionContext));
            }

            var extendedContentRepositry = contentRepository.AsExtendableContentRepository();
            var newRepository            = extendedContentRepositry.ServiceProvider.GetRequiredService <IContentRepositoryWithCustomExecutionContext>();

            newRepository.SetExecutionContext(executionContext);

            return(newRepository);
        }
 public SendBookingMailCommandHandler(
     IAdvancedContentRepository domainRepository,
     IBookingProvider bookingProvider,
     IMailDispatchService mailDispatchService,
     ICommandExecutor commandExecutor,
     IPermissionValidationService permissionValidationService,
     ICurrentUserProvider currentUserProvider)
 {
     DomainRepository            = domainRepository;
     BookingProvider             = bookingProvider;
     MailDispatchService         = mailDispatchService;
     CommandExecutor             = commandExecutor;
     PermissionValidationService = permissionValidationService;
     CurrentUserProvider         = currentUserProvider;
 }
示例#17
0
 public CheckoutBookingCommandHandler(
     IAdvancedContentRepository domainRepository,
     IBookingProvider bookingProvider,
     ITemplateProvider templateProvider,
     IMailDispatchService mailDispatchService,
     ICommandExecutor commandExecutor,
     BookingSettings bookingSettings,
     ICurrentUserProvider currentUserProvider)
 {
     DomainRepository    = domainRepository;
     BookingProvider     = bookingProvider;
     TemplateProvider    = templateProvider;
     MailDispatchService = mailDispatchService;
     CommandExecutor     = commandExecutor;
     BookingSettings     = bookingSettings;
     CurrentUserProvider = currentUserProvider;
 }
示例#18
0
 public BookingRequestCommandHandler(
     IAdvancedContentRepository domainRepository,
     ISequenceNumberGenerator sequenceNumberGenerator,
     ITemplateProvider templateProvider,
     ITenantCategoryProvider tenantCategoryProvider,
     IMailDispatchService mailDispatchService,
     ICommandExecutor commandExecutor,
     BookingSettings bookingSettings,
     ICurrentUserProvider currentUserProvider)
 {
     DomainRepository        = domainRepository;
     SequenceNumberGenerator = sequenceNumberGenerator;
     TemplateProvider        = templateProvider;
     TenantCategoryProvider  = tenantCategoryProvider;
     MailDispatchService     = mailDispatchService;
     CommandExecutor         = commandExecutor;
     BookingSettings         = bookingSettings;
     CurrentUserProvider     = currentUserProvider;
 }
示例#19
0
 /// <summary>
 /// Execute queries or commands using the user context associated with the
 /// specified user area. This is useful when implementing multiple user areas
 /// whereby a client can be signed into multiple user accounts belonging to
 /// different user areas. Use this to force execution to use the context
 /// of a specific user area rather than relying on the "ambient" or default.
 /// </summary>
 /// <typeparam name="TUserAreaDefinition">
 /// The user area to use when determining the signed in user to execute
 /// tasks with.
 /// </typeparam>
 public static IAdvancedContentRepository WithContext <TUserAreaDefinition>(this IAdvancedContentRepository repository)
     where TUserAreaDefinition : IUserAreaDefinition
 {
     return((IAdvancedContentRepository)IDomainRepositoryExtensions.WithContext <TUserAreaDefinition>(repository));
 }
示例#20
0
        /// <summary>
        /// Runs any queries or commands chained off this instance under
        /// the system user account which has no permission restrictions.
        /// This is useful when you need to perform an action that the currently
        /// logged in user does not have permission for, e.g. signing up a new
        /// user prior to login.
        /// </summary>
        public static IAdvancedContentRepository WithElevatedPermissions(this IAdvancedContentRepository contentRepository)
        {
            var extendedApi = contentRepository.AsExtendableContentRepository();

            return(extendedApi.ServiceProvider.GetRequiredService <IContentRepositoryWithElevatedPermissions>());
        }
示例#21
0
 /// <summary>
 /// Queries and commands relating to users from the Cofoundry identity
 /// system. This includes users from both the Cofoundry admin user area
 /// and any custom user areas.
 /// </summary>
 public static IAdvancedContentRepositoryUserRepository Users(this IAdvancedContentRepository contentRepository)
 {
     return(new ContentRepositoryUserRepository(contentRepository.AsExtendableContentRepository()));
 }
 public TenantCategoryProvider(
     IAdvancedContentRepository contentRepository)
     : base(contentRepository)
 {
 }
示例#23
0
 public static IExtendableContentRepository AsExtendableContentRepository(this IAdvancedContentRepository contentRepository)
 {
     return(CastToExtendableContentRepository(contentRepository));
 }
示例#24
0
 public SignMemberInCommandHandler(
     IAdvancedContentRepository contentRepository
     )
 {
     _contentRepository = contentRepository;
 }
 /// <summary>
 /// Custom entities are a flexible system for developer defined
 /// data structures which can be fully managed in the admin panel
 /// with minimal configuration.
 /// </summary>
 public static IAdvancedContentRepositoryCustomEntityRepository CustomEntities(this IAdvancedContentRepository contentRepository)
 {
     return(new AdvancedContentRepositoryCustomEntityRepository(contentRepository.AsExtendableContentRepository()));
 }
 /// <summary>
 /// Page block types represent a type of content that can be inserted into a content
 /// region of a page which could be simple content like 'RawHtml', 'Image' or
 /// 'PlainText'. Custom and more complex block types can be defined by a
 /// developer. Block types are typically created when the application
 /// starts up in the auto-update process.
 /// </summary>
 public static IAdvancedContentRepositoryPageBlockTypeRepository PageBlockTypes(this IAdvancedContentRepository contentRepository)
 {
     return(new ContentRepositoryPageBlockTypeRepository(contentRepository.AsExtendableContentRepository()));
 }
 /// <summary>
 /// <para>
 /// Authorized tasks represent a single user-based operation that can be executed without
 /// being logged in. Task authorization is validated by a crytographically random
 /// generated token, often communicated via an out-of-band communication mechanism
 /// such as an email. Examples include password reset or email address validation flows.
 /// </para>
 /// <para>
 /// Tasks tend to be single-use and can be marked when completed, and can also be
 /// invalidated explicitly. They can also be rate-limited by IPAddress and time-limited
 /// by validating against the <see cref="CreateDate"/>.
 /// </para>
 /// </summary>
 public static IAdvancedContentRepositoryAuthorizedTaskRepository AuthorizedTasks(this IAdvancedContentRepository contentRepository)
 {
     return(new ContentRepositoryAuthorizedTaskRepository(contentRepository.AsExtendableContentRepository()));
 }
 /// <summary>
 /// PageDirectories represent a folder in the dynamic web page hierarchy.
 /// </summary>
 public static IAdvancedContentRepositoryPageDirectoryRepository PageDirectories(this IAdvancedContentRepository contentRepository)
 {
     return(new AdvancedContentRepositoryPageDirectoryRepository(contentRepository.AsExtendableContentRepository()));
 }
示例#29
0
 /// <summary>
 /// Queries and commands relating to document assets.
 /// </summary>
 public static IAdvancedContentRepositoryDocumentAssetRepository DocumentAssets(this IAdvancedContentRepository contentRepository)
 {
     return(new AdvancedContentRepositoryDocumentAssetRepository(contentRepository.AsExtendableContentRepository()));
 }
示例#30
0
 /// <summary>
 /// Rewrite rules can be used to redirect users from one url to another.
 /// This functionality is incomplete and subject to change.
 /// </summary>
 public static IAdvancedContentRepositoryRewriteRuleRepository RewriteRules(this IAdvancedContentRepository contentRepository)
 {
     return(new ContentRepositoryRewriteRuleRepository(contentRepository.AsExtendableContentRepository()));
 }