public MemberService() { _memberService = AppHelpers.UmbServices().MemberService; _memberGroupService = AppHelpers.UmbServices().MemberGroupService; _membershipHelper = AppHelpers.UmbMemberHelper(); _memberTypeService = AppHelpers.UmbServices().MemberTypeService; _dataTypeService = AppHelpers.UmbServices().DataTypeService; }
///Constructors needed for testability and DI public MemberRegisterSurfaceController(UmbracoContext umbracoContext, IMemberTypeService _memberTypeService, IMemberService _memberService) : base(umbracoContext) { this._memberTypeService = _memberTypeService; this._memberService = _memberService; }
// default ctor public PublishedContentTypeCache(IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, IPublishedContentTypeFactory publishedContentTypeFactory, ILogger <PublishedContentTypeCache> logger) { _contentTypeService = contentTypeService; _mediaTypeService = mediaTypeService; _memberTypeService = memberTypeService; _logger = logger; _publishedContentTypeFactory = publishedContentTypeFactory; }
public MemberServiceHelper(IMemberService memberService, IMemberTypeService memberTypeService) { _memberService = memberService; _memberTypeService = memberTypeService; }
public MemberMapperProfile( MemberTabsAndPropertiesResolver tabsAndPropertiesResolver, MemberTreeNodeUrlResolver memberTreeNodeUrlResolver, MemberBasicPropertiesResolver memberBasicPropertiesResolver, IUserService userService, IMemberTypeService memberTypeService, IMemberService memberService) { // create, capture, cache var memberOwnerResolver = new OwnerResolver <IMember>(userService); var memberProfiderFieldMappingResolver = new MemberProviderFieldResolver(); var membershipScenarioMappingResolver = new MembershipScenarioResolver(memberTypeService); var memberDtoPropertiesResolver = new MemberDtoPropertiesResolver(); //FROM MembershipUser TO MediaItemDisplay - used when using a non-umbraco membership provider CreateMap <MembershipUser, MemberDisplay>().ConvertUsing <MembershipUserTypeConverter>(); //FROM MembershipUser TO IMember - used when using a non-umbraco membership provider CreateMap <MembershipUser, IMember>() .ConstructUsing(src => MemberService.CreateGenericMembershipProviderMember(src.UserName, src.Email, src.UserName, "")) //we're giving this entity an ID of int.MaxValue - TODO: SD: I can't remember why this mapping is here? .ForMember(dest => dest.Id, opt => opt.MapFrom(src => int.MaxValue)) .ForMember(dest => dest.Comments, opt => opt.MapFrom(src => src.Comment)) .ForMember(dest => dest.CreateDate, opt => opt.MapFrom(src => src.CreationDate)) .ForMember(dest => dest.UpdateDate, opt => opt.MapFrom(src => src.LastActivityDate)) .ForMember(dest => dest.LastPasswordChangeDate, opt => opt.MapFrom(src => src.LastPasswordChangedDate)) .ForMember(dest => dest.Key, opt => opt.MapFrom(src => src.ProviderUserKey.TryConvertTo <Guid>().Result.ToString("N"))) //This is a special case for password - we don't actually care what the password is but it either needs to be something or nothing // so we'll set it to something if the member is actually created, otherwise nothing if it is a new member. .ForMember(dest => dest.RawPasswordValue, opt => opt.MapFrom(src => src.CreationDate > DateTime.MinValue ? Guid.NewGuid().ToString("N") : "")) .ForMember(dest => dest.Properties, opt => opt.Ignore()) .ForMember(dest => dest.CreatorId, opt => opt.Ignore()) .ForMember(dest => dest.Level, opt => opt.Ignore()) .ForMember(dest => dest.Name, opt => opt.Ignore()) .ForMember(dest => dest.CultureInfos, opt => opt.Ignore()) .ForMember(dest => dest.ParentId, opt => opt.Ignore()) .ForMember(dest => dest.Path, opt => opt.Ignore()) .ForMember(dest => dest.SortOrder, opt => opt.Ignore()) .ForMember(dest => dest.AdditionalData, opt => opt.Ignore()) .ForMember(dest => dest.FailedPasswordAttempts, opt => opt.Ignore()) .ForMember(dest => dest.DeleteDate, opt => opt.Ignore()) .ForMember(dest => dest.WriterId, opt => opt.Ignore()) .ForMember(dest => dest.VersionId, opt => opt.Ignore()) // TODO: Support these eventually .ForMember(dest => dest.PasswordQuestion, opt => opt.Ignore()) .ForMember(dest => dest.RawPasswordAnswerValue, opt => opt.Ignore()); //FROM IMember TO MemberDisplay CreateMap <IMember, MemberDisplay>() .ForMember(dest => dest.Udi, opt => opt.MapFrom(content => Udi.Create(Constants.UdiEntityType.Member, content.Key))) .ForMember(dest => dest.Owner, opt => opt.MapFrom(src => memberOwnerResolver.Resolve(src))) .ForMember(dest => dest.Icon, opt => opt.MapFrom(src => src.ContentType.Icon)) .ForMember(dest => dest.ContentTypeAlias, opt => opt.MapFrom(src => src.ContentType.Alias)) .ForMember(dest => dest.ContentTypeName, opt => opt.MapFrom(src => src.ContentType.Name)) .ForMember(dest => dest.Properties, opt => opt.Ignore()) .ForMember(dest => dest.Tabs, opt => opt.MapFrom(tabsAndPropertiesResolver)) .ForMember(dest => dest.MemberProviderFieldMapping, opt => opt.MapFrom(src => memberProfiderFieldMappingResolver.Resolve(src))) .ForMember(dest => dest.MembershipScenario, opt => opt.MapFrom(src => membershipScenarioMappingResolver.Resolve(src))) .ForMember(dest => dest.Notifications, opt => opt.Ignore()) .ForMember(dest => dest.Errors, opt => opt.Ignore()) .ForMember(dest => dest.State, opt => opt.MapFrom <ContentSavedState?>(_ => null)) .ForMember(dest => dest.Edited, opt => opt.Ignore()) .ForMember(dest => dest.Updater, opt => opt.Ignore()) .ForMember(dest => dest.Alias, opt => opt.Ignore()) .ForMember(dest => dest.IsChildOfListView, opt => opt.Ignore()) .ForMember(dest => dest.Trashed, opt => opt.Ignore()) .ForMember(dest => dest.IsContainer, opt => opt.Ignore()) .ForMember(dest => dest.TreeNodeUrl, opt => opt.MapFrom(memberTreeNodeUrlResolver)) .ForMember(dest => dest.VariesByCulture, opt => opt.Ignore()); //FROM IMember TO MemberBasic CreateMap <IMember, MemberBasic>() //we're giving this entity an ID of int.MaxValue - this is kind of a hack to force angular to use the Key instead of the Id in list views .ForMember(dest => dest.Id, opt => opt.MapFrom(src => int.MaxValue)) .ForMember(dest => dest.Udi, opt => opt.MapFrom(content => Udi.Create(Constants.UdiEntityType.Member, content.Key))) .ForMember(dest => dest.Owner, opt => opt.MapFrom(src => memberOwnerResolver.Resolve(src))) .ForMember(dest => dest.Icon, opt => opt.MapFrom(src => src.ContentType.Icon)) .ForMember(dest => dest.ContentTypeAlias, opt => opt.MapFrom(src => src.ContentType.Alias)) .ForMember(dest => dest.Email, opt => opt.MapFrom(src => src.Email)) .ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.Username)) .ForMember(dest => dest.Trashed, opt => opt.Ignore()) .ForMember(dest => dest.State, opt => opt.MapFrom <ContentSavedState?>(_ => null)) .ForMember(dest => dest.Edited, opt => opt.Ignore()) .ForMember(dest => dest.Updater, opt => opt.Ignore()) .ForMember(dest => dest.Alias, opt => opt.Ignore()) .ForMember(dto => dto.Properties, expression => expression.MapFrom(memberBasicPropertiesResolver)) .ForMember(dest => dest.VariesByCulture, opt => opt.Ignore()); //FROM MembershipUser TO MemberBasic CreateMap <MembershipUser, MemberBasic>() //we're giving this entity an ID of int.MaxValue - TODO: SD: I can't remember why this mapping is here? .ForMember(dest => dest.Id, opt => opt.MapFrom(src => int.MaxValue)) .ForMember(dest => dest.Udi, opt => opt.Ignore()) .ForMember(dest => dest.CreateDate, opt => opt.MapFrom(src => src.CreationDate)) .ForMember(dest => dest.UpdateDate, opt => opt.MapFrom(src => src.LastActivityDate)) .ForMember(dest => dest.Key, opt => opt.MapFrom(src => src.ProviderUserKey.TryConvertTo <Guid>().Result.ToString("N"))) .ForMember(dest => dest.Owner, opt => opt.MapFrom(_ => new UserProfile { Name = "Admin", UserId = -1 })) .ForMember(dest => dest.Icon, opt => opt.MapFrom(_ => "icon-user")) .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.UserName)) .ForMember(dest => dest.Email, opt => opt.MapFrom(src => src.Email)) .ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.UserName)) .ForMember(dest => dest.Properties, opt => opt.Ignore()) .ForMember(dest => dest.ParentId, opt => opt.Ignore()) .ForMember(dest => dest.Path, opt => opt.Ignore()) .ForMember(dest => dest.SortOrder, opt => opt.Ignore()) .ForMember(dest => dest.AdditionalData, opt => opt.Ignore()) .ForMember(dest => dest.State, opt => opt.MapFrom(_ => ContentSavedState.Draft)) .ForMember(dest => dest.Edited, opt => opt.Ignore()) .ForMember(dest => dest.Updater, opt => opt.Ignore()) .ForMember(dest => dest.Trashed, opt => opt.Ignore()) .ForMember(dest => dest.Alias, opt => opt.Ignore()) .ForMember(dest => dest.ContentTypeAlias, opt => opt.Ignore()) .ForMember(dest => dest.VariesByCulture, opt => opt.Ignore()); //FROM IMember TO ContentItemDto<IMember> CreateMap <IMember, ContentPropertyCollectionDto>() //.ForMember(dest => dest.Udi, opt => opt.MapFrom(content => Udi.Create(Constants.UdiEntityType.Member, content.Key))) //.ForMember(dest => dest.Owner, opt => opt.MapFrom(src => memberOwnerResolver.Resolve(src))) //.ForMember(dest => dest.Published, opt => opt.Ignore()) //.ForMember(dest => dest.Edited, opt => opt.Ignore()) //.ForMember(dest => dest.Updater, opt => opt.Ignore()) //.ForMember(dest => dest.Icon, opt => opt.Ignore()) //.ForMember(dest => dest.Alias, opt => opt.Ignore()) //do no map the custom member properties (currently anyways, they were never there in 6.x) .ForMember(dest => dest.Properties, opt => opt.MapFrom(src => memberDtoPropertiesResolver.Resolve(src))); //FROM IMemberGroup TO MemberGroupDisplay CreateMap <IMemberGroup, MemberGroupDisplay>() .ForMember(dest => dest.Udi, opt => opt.MapFrom(src => Udi.Create(Constants.UdiEntityType.MemberGroup, src.Key))) .ForMember(dest => dest.Path, opt => opt.MapFrom(group => "-1," + group.Id)) .ForMember(dest => dest.Notifications, opt => opt.Ignore()) .ForMember(dest => dest.Icon, opt => opt.Ignore()) .ForMember(dest => dest.Trashed, opt => opt.Ignore()) .ForMember(dest => dest.ParentId, opt => opt.Ignore()) .ForMember(dest => dest.Alias, opt => opt.Ignore()); }
public MemberModelBuilderBase(IMemberTypeService memberTypeService, IShortStringHelper shortStringHelper) { MemberTypeService = memberTypeService; _shortStringHelper = shortStringHelper; }
/// <summary> /// public ctor - will generally just be used for unit testing all items are optional and if not specified, the defaults will be used /// </summary> public ServiceContext( IContentService contentService = null, IMediaService mediaService = null, IContentTypeService contentTypeService = null, IDataTypeService dataTypeService = null, IFileService fileService = null, ILocalizationService localizationService = null, IPackagingService packagingService = null, IEntityService entityService = null, IRelationService relationService = null, IMemberGroupService memberGroupService = null, IMemberTypeService memberTypeService = null, IMemberService memberService = null, IUserService userService = null, ISectionService sectionService = null, IApplicationTreeService treeService = null, ITagService tagService = null, INotificationService notificationService = null, ILocalizedTextService localizedTextService = null, IAuditService auditService = null, IDomainService domainService = null, ITaskService taskService = null, IMacroService macroService = null, IPublicAccessService publicAccessService = null, IExternalLoginService externalLoginService = null, IMigrationEntryService migrationEntryService = null, IRedirectUrlService redirectUrlService = null, IConsentService consentService = null) { if (migrationEntryService != null) { _migrationEntryService = new Lazy <IMigrationEntryService>(() => migrationEntryService); } if (externalLoginService != null) { _externalLoginService = new Lazy <IExternalLoginService>(() => externalLoginService); } if (auditService != null) { _auditService = new Lazy <IAuditService>(() => auditService); } if (localizedTextService != null) { _localizedTextService = new Lazy <ILocalizedTextService>(() => localizedTextService); } if (tagService != null) { _tagService = new Lazy <ITagService>(() => tagService); } if (contentService != null) { _contentService = new Lazy <IContentService>(() => contentService); } if (mediaService != null) { _mediaService = new Lazy <IMediaService>(() => mediaService); } if (contentTypeService != null) { _contentTypeService = new Lazy <IContentTypeService>(() => contentTypeService); } if (dataTypeService != null) { _dataTypeService = new Lazy <IDataTypeService>(() => dataTypeService); } if (fileService != null) { _fileService = new Lazy <IFileService>(() => fileService); } if (localizationService != null) { _localizationService = new Lazy <ILocalizationService>(() => localizationService); } if (packagingService != null) { _packagingService = new Lazy <IPackagingService>(() => packagingService); } if (entityService != null) { _entityService = new Lazy <IEntityService>(() => entityService); } if (relationService != null) { _relationService = new Lazy <IRelationService>(() => relationService); } if (sectionService != null) { _sectionService = new Lazy <ISectionService>(() => sectionService); } if (memberGroupService != null) { _memberGroupService = new Lazy <IMemberGroupService>(() => memberGroupService); } if (memberTypeService != null) { _memberTypeService = new Lazy <IMemberTypeService>(() => memberTypeService); } if (treeService != null) { _treeService = new Lazy <IApplicationTreeService>(() => treeService); } if (memberService != null) { _memberService = new Lazy <IMemberService>(() => memberService); } if (userService != null) { _userService = new Lazy <IUserService>(() => userService); } if (notificationService != null) { _notificationService = new Lazy <INotificationService>(() => notificationService); } if (domainService != null) { _domainService = new Lazy <IDomainService>(() => domainService); } if (taskService != null) { _taskService = new Lazy <ITaskService>(() => taskService); } if (macroService != null) { _macroService = new Lazy <IMacroService>(() => macroService); } if (publicAccessService != null) { _publicAccessService = new Lazy <IPublicAccessService>(() => publicAccessService); } if (redirectUrlService != null) { _redirectUrlService = new Lazy <IRedirectUrlService>(() => redirectUrlService); } if (consentService != null) { _consentService = new Lazy <IConsentService>(() => consentService); } }
private void MemberTypeService_Saved(IMemberTypeService sender, SaveEventArgs <IMemberType> args) { }
/// <summary> /// Create member controller to test /// </summary> /// <param name="memberService">Member service</param> /// <param name="memberTypeService">Member type service</param> /// <param name="memberGroupService">Member group service</param> /// <param name="membersUserManager">Members user manager</param> /// <param name="dataTypeService">Data type service</param> /// <param name="backOfficeSecurityAccessor">Back office security accessor</param> /// <param name="mockPasswordChanger">Password changer class</param> /// <returns>A member controller for the tests</returns> private MemberController CreateSut( IMemberService memberService, IMemberTypeService memberTypeService, IMemberGroupService memberGroupService, IUmbracoUserManager <MemberIdentityUser> membersUserManager, IDataTypeService dataTypeService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IPasswordChanger <MemberIdentityUser> passwordChanger, IOptions <GlobalSettings> globalSettings, IUser user) { var httpContextAccessor = new HttpContextAccessor(); var mockShortStringHelper = new MockShortStringHelper(); var textService = new Mock <ILocalizedTextService>(); var contentTypeBaseServiceProvider = new Mock <IContentTypeBaseServiceProvider>(); contentTypeBaseServiceProvider.Setup(x => x.GetContentTypeOf(It.IsAny <IContentBase>())).Returns(new ContentType(mockShortStringHelper, 123)); var contentAppFactories = new Mock <List <IContentAppFactory> >(); var mockContentAppFactoryCollection = new Mock <ILogger <ContentAppFactoryCollection> >(); var hybridBackOfficeSecurityAccessor = new BackOfficeSecurityAccessor(httpContextAccessor); var contentAppFactoryCollection = new ContentAppFactoryCollection( () => contentAppFactories.Object, mockContentAppFactoryCollection.Object, hybridBackOfficeSecurityAccessor); var mockUserService = new Mock <IUserService>(); var commonMapper = new CommonMapper( mockUserService.Object, contentTypeBaseServiceProvider.Object, contentAppFactoryCollection, textService.Object); var mockCultureDictionary = new Mock <ICultureDictionary>(); var mockPasswordConfig = new Mock <IOptions <MemberPasswordConfigurationSettings> >(); mockPasswordConfig.Setup(x => x.Value).Returns(() => new MemberPasswordConfigurationSettings()); IDataEditor dataEditor = Mock.Of <IDataEditor>( x => x.Type == EditorType.PropertyValue && x.Alias == Constants.PropertyEditors.Aliases.Label); Mock.Get(dataEditor).Setup(x => x.GetValueEditor()).Returns(new TextOnlyValueEditor(new DataEditorAttribute(Constants.PropertyEditors.Aliases.TextBox, "Test Textbox", "textbox"), textService.Object, Mock.Of <IShortStringHelper>(), Mock.Of <IJsonSerializer>(), Mock.Of <IIOHelper>())); var propertyEditorCollection = new PropertyEditorCollection(new DataEditorCollection(() => new[] { dataEditor })); IMapDefinition memberMapDefinition = new MemberMapDefinition( commonMapper, new CommonTreeNodeMapper(Mock.Of <LinkGenerator>()), new MemberTabsAndPropertiesMapper( mockCultureDictionary.Object, backOfficeSecurityAccessor, textService.Object, memberTypeService, memberService, memberGroupService, mockPasswordConfig.Object, contentTypeBaseServiceProvider.Object, propertyEditorCollection)); var map = new MapDefinitionCollection(() => new List <IMapDefinition>() { new global::Umbraco.Cms.Core.Models.Mapping.MemberMapDefinition(), memberMapDefinition, new ContentTypeMapDefinition( commonMapper, propertyEditorCollection, dataTypeService, new Mock <IFileService>().Object, new Mock <IContentTypeService>().Object, new Mock <IMediaTypeService>().Object, memberTypeService, new Mock <ILoggerFactory>().Object, mockShortStringHelper, globalSettings, new Mock <IHostingEnvironment>().Object, new Mock <IOptionsMonitor <ContentSettings> >().Object) }); var scopeProvider = Mock.Of <ICoreScopeProvider>(x => x.CreateCoreScope( It.IsAny <IsolationLevel>(), It.IsAny <RepositoryCacheMode>(), It.IsAny <IEventDispatcher>(), It.IsAny <IScopedNotificationPublisher>(), It.IsAny <bool?>(), It.IsAny <bool>(), It.IsAny <bool>()) == Mock.Of <ICoreScope>()); _mapper = new UmbracoMapper(map, scopeProvider); return(new MemberController( new DefaultCultureDictionary( new Mock <ILocalizationService>().Object, NoAppCache.Instance), new LoggerFactory(), mockShortStringHelper, new DefaultEventMessagesFactory( new Mock <IEventMessagesAccessor>().Object), textService.Object, propertyEditorCollection, _mapper, memberService, memberTypeService, (IMemberManager)membersUserManager, dataTypeService, backOfficeSecurityAccessor, new ConfigurationEditorJsonSerializer(), passwordChanger, scopeProvider )); }
public async Task PostSaveMember_SaveExistingMember_WithNoRoles_Add1Role_ExpectSuccessResponse( [Frozen] IMemberManager umbracoMembersUserManager, IMemberService memberService, IMemberTypeService memberTypeService, IMemberGroupService memberGroupService, IDataTypeService dataTypeService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IBackOfficeSecurity backOfficeSecurity, IPasswordChanger <MemberIdentityUser> passwordChanger, IOptions <GlobalSettings> globalSettings, IUser user) { // arrange var roleName = "anyrole"; IMember member = SetupMemberTestData(out MemberSave fakeMemberData, out MemberDisplay memberDisplay, ContentSaveAction.Save); fakeMemberData.Groups = new List <string>() { roleName }; var membersIdentityUser = new MemberIdentityUser(123); Mock.Get(umbracoMembersUserManager) .Setup(x => x.FindByIdAsync(It.IsAny <string>())) .ReturnsAsync(() => membersIdentityUser); Mock.Get(umbracoMembersUserManager) .Setup(x => x.ValidatePasswordAsync(It.IsAny <string>())) .ReturnsAsync(() => IdentityResult.Success); Mock.Get(umbracoMembersUserManager) .Setup(x => x.UpdateAsync(It.IsAny <MemberIdentityUser>())) .ReturnsAsync(() => IdentityResult.Success); Mock.Get(umbracoMembersUserManager) .Setup(x => x.AddToRolesAsync(It.IsAny <MemberIdentityUser>(), It.IsAny <IEnumerable <string> >())) .ReturnsAsync(() => IdentityResult.Success); Mock.Get(umbracoMembersUserManager) .Setup(x => x.GetRolesAsync(It.IsAny <MemberIdentityUser>())) .ReturnsAsync(() => Array.Empty <string>()); Mock.Get(memberTypeService).Setup(x => x.GetDefault()).Returns("fakeAlias"); Mock.Get(backOfficeSecurityAccessor).Setup(x => x.BackOfficeSecurity).Returns(backOfficeSecurity); Mock.Get(memberService).Setup(x => x.GetByUsername(It.IsAny <string>())).Returns(() => member); Mock.Get(memberService).Setup(x => x.GetById(It.IsAny <int>())).Returns(() => member); SetupUserAccess(backOfficeSecurityAccessor, backOfficeSecurity, user); SetupPasswordSuccess(umbracoMembersUserManager, passwordChanger); Mock.Get(memberService).SetupSequence( x => x.GetByEmail(It.IsAny <string>())) .Returns(() => null) .Returns(() => member); MemberController sut = CreateSut(memberService, memberTypeService, memberGroupService, umbracoMembersUserManager, dataTypeService, backOfficeSecurityAccessor, passwordChanger, globalSettings, user); // act ActionResult <MemberDisplay> result = await sut.PostSave(fakeMemberData); // assert Assert.IsNull(result.Result); Assert.IsNotNull(result.Value); Mock.Get(umbracoMembersUserManager) .Verify(u => u.GetRolesAsync(membersIdentityUser)); Mock.Get(umbracoMembersUserManager) .Verify(u => u.AddToRolesAsync(membersIdentityUser, new[] { roleName })); Mock.Get(umbracoMembersUserManager) .Verify(x => x.GetRolesAsync(It.IsAny <MemberIdentityUser>())); Mock.Get(memberService) .Verify(m => m.Save(It.IsAny <Member>())); AssertMemberDisplayPropertiesAreEqual(memberDisplay, result.Value); }
public MemberTabsAndPropertiesMapper(IUmbracoContextAccessor umbracoContextAccessor, ILocalizedTextService localizedTextService, IMemberService memberService, IUserService userService, IMemberTypeService memberTypeService) : base(localizedTextService) { _umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor)); _localizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService)); _memberService = memberService ?? throw new ArgumentNullException(nameof(memberService)); _userService = userService ?? throw new ArgumentNullException(nameof(userService)); _memberTypeService = memberTypeService ?? throw new ArgumentNullException(nameof(memberTypeService)); }
public ContentTypeMapDefinition(PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IFileService fileService, IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, ILogger logger) { _propertyEditors = propertyEditors; _dataTypeService = dataTypeService; _fileService = fileService; _contentTypeService = contentTypeService; _mediaTypeService = mediaTypeService; _memberTypeService = memberTypeService; _logger = logger; }
public void Get_Paged_Mixed_Entities_By_Ids() { // Create content IContentService contentService = GetRequiredService <IContentService>(); IContentTypeService contentTypeService = GetRequiredService <IContentTypeService>(); var createdContent = new List <IContent>(); ContentType contentType = ContentTypeBuilder.CreateBasicContentType("blah"); contentTypeService.Save(contentType); for (int i = 0; i < 10; i++) { Content c1 = ContentBuilder.CreateBasicContent(contentType); contentService.Save(c1); createdContent.Add(c1); } // Create media IMediaService mediaService = GetRequiredService <IMediaService>(); IMediaTypeService mediaTypeService = GetRequiredService <IMediaTypeService>(); var createdMedia = new List <IMedia>(); MediaType imageType = MediaTypeBuilder.CreateImageMediaType("myImage"); mediaTypeService.Save(imageType); for (int i = 0; i < 10; i++) { Media c1 = MediaBuilder.CreateMediaImage(imageType, -1); mediaService.Save(c1); createdMedia.Add(c1); } // Create members IMemberService memberService = GetRequiredService <IMemberService>(); IMemberTypeService memberTypeService = GetRequiredService <IMemberTypeService>(); MemberType memberType = MemberTypeBuilder.CreateSimpleMemberType("simple"); memberTypeService.Save(memberType); var createdMembers = MemberBuilder.CreateMultipleSimpleMembers(memberType, 10).ToList(); memberService.Save(createdMembers); IScopeProvider provider = ScopeProvider; using (provider.CreateScope()) { EntityRepository repo = CreateRepository((IScopeAccessor)provider); IEnumerable <int> ids = createdContent.Select(x => x.Id).Concat(createdMedia.Select(x => x.Id)).Concat(createdMembers.Select(x => x.Id)); System.Guid[] objectTypes = new[] { Constants.ObjectTypes.Document, Constants.ObjectTypes.Media, Constants.ObjectTypes.Member }; IQuery <IUmbracoEntity> query = provider.SqlContext.Query <IUmbracoEntity>() .WhereIn(e => e.Id, ids); var entities = repo.GetPagedResultsByQuery(query, objectTypes, 0, 20, out long totalRecords, null, null).ToList(); Assert.AreEqual(20, entities.Count); Assert.AreEqual(30, totalRecords); // add the next page entities.AddRange(repo.GetPagedResultsByQuery(query, objectTypes, 1, 20, out totalRecords, null, null)); Assert.AreEqual(30, entities.Count); Assert.AreEqual(30, totalRecords); var contentEntities = entities.OfType <IDocumentEntitySlim>().ToList(); var mediaEntities = entities.OfType <IMediaEntitySlim>().ToList(); var memberEntities = entities.OfType <IMemberEntitySlim>().ToList(); Assert.AreEqual(10, contentEntities.Count); Assert.AreEqual(10, mediaEntities.Count); Assert.AreEqual(10, memberEntities.Count); } }
private void MemberTypeService_Deleted(IMemberTypeService sender, DeleteEventArgs <IMemberType> args) { }
public MemberTypesController(IMemberTypeService MemberTypesService) { _MemberTypesService = MemberTypesService; }
public BackOfficeUserStore(IUserService userService, IMemberTypeService memberTypeService, IEntityService entityService, IExternalLoginService externalLoginService, IGlobalSettings globalSettings, MembershipProviderBase usersMembershipProvider, UmbracoMapper mapper) : this(userService, memberTypeService, entityService, externalLoginService, globalSettings, usersMembershipProvider, mapper, Current.AppCaches) { }
private void MemberTypeService_Changed(IMemberTypeService sender, ContentTypeChange <IMemberType> .EventArgs args) { _distributedCache.RefreshContentTypeCache(args.Changes.ToArray()); }