umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.42k stars 2.67k forks source link

Extend MemberService GetCount method #2986

Closed bjarnef closed 5 years ago

bjarnef commented 6 years ago

The GetCount in MemberService has been added recently I guess (since it wasn't documented https://github.com/umbraco/UmbracoDocs/pull/975). However it would be great to have an overload method to specify member type, e.g. count all members of type Customer.

The signature could be like:

public GetCount(MemberCountType memberCountType)

public GetCount(string memberAlias)

public GetCount(MemberCountType memberCountType, string memberAlias)

With ModelsBuilder it could be used something like this, which would use the signature GetCount(string memberAlias):

 ms.GetCount(Umbraco.Web.PublishedContentModels.Customer.ModelTypeAlias)

I am not sure if there could be another specific signature for ModelsBuilder? Maybe this?

 ms.GetCount(Umbraco.Core.Models.PublishedItemType itemType)

Furthermore for MemberService GetPagedXmlEntries maybe an overload to specify member type alias performs better than the following?

var customers = ms.GetPagedXmlEntries(1, 50, out var total).OfType<Umbraco.Web.PublishedContentModels.Customer>();
bjarnef commented 5 years ago

I noticed there wasn't a GetCount() method, but just a Count() for member type: https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Core/Services/MemberService.cs#L721-L734

public int Count(string memberTypeAlias = null)
{
    using (var uow = UowProvider.GetUnitOfWork(readOnly: true))
    {
        var repository = RepositoryFactory.CreateMemberRepository(uow);
        return repository.Count(memberTypeAlias);
    }
}
nul800sebastiaan commented 5 years ago

Thanks @bjarnef - it looks like this functionality is now available in v8.

image