Finishes wrapping the member service and fixes a few bugs - ensures the RepositoryBase doesn't keep enumerating when getting all
This commit is contained in:
@@ -55,7 +55,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// <param name="entity"></param>
|
||||
public void AddOrUpdate(TEntity entity)
|
||||
{
|
||||
if (!entity.HasIdentity)
|
||||
if (entity.HasIdentity == false)
|
||||
{
|
||||
_work.RegisterAdded(entity, this);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
//on initial construction we don't want to have dirty properties tracked
|
||||
// http://issues.umbraco.org/issue/U4-1946
|
||||
TracksChangesEntityBase asEntity = entity as TracksChangesEntityBase;
|
||||
var asEntity = entity as TracksChangesEntityBase;
|
||||
if (asEntity != null)
|
||||
{
|
||||
asEntity.ResetDirtyProperties(false);
|
||||
@@ -132,13 +132,16 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
if (ids.Any())
|
||||
{
|
||||
var entities = _cache.GetByIds(typeof(TEntity), ids.Select(id => id is int ? ConvertIdToGuid(id) : ConvertStringIdToGuid(id.ToString())).ToList());
|
||||
var entities = _cache.GetByIds(
|
||||
typeof (TEntity), ids.Select(id => id is int ? ConvertIdToGuid(id) : ConvertStringIdToGuid(id.ToString())).ToList())
|
||||
.ToArray();
|
||||
|
||||
if (ids.Count().Equals(entities.Count()) && entities.Any(x => x == null) == false)
|
||||
return entities.Select(x => (TEntity)x);
|
||||
}
|
||||
else
|
||||
{
|
||||
var allEntities = _cache.GetAllByType(typeof(TEntity));
|
||||
var allEntities = _cache.GetAllByType(typeof (TEntity)).ToArray();
|
||||
|
||||
if (allEntities.Any())
|
||||
{
|
||||
@@ -151,7 +154,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
}
|
||||
}
|
||||
|
||||
var entityCollection = PerformGetAll(ids);
|
||||
var entityCollection = PerformGetAll(ids).ToArray();
|
||||
|
||||
foreach (var entity in entityCollection)
|
||||
{
|
||||
|
||||
@@ -676,7 +676,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
using (var repository = _repositoryFactory.CreateMemberRepository(_uowProvider.GetUnitOfWork()))
|
||||
{
|
||||
var query = Query<IMember>.Builder.Where(x => x.Username == userName);
|
||||
var query = Query<IMember>.Builder.Where(x => x.Username.Equals(userName));
|
||||
var member = repository.GetByQuery(query).FirstOrDefault();
|
||||
|
||||
return member;
|
||||
|
||||
@@ -217,11 +217,15 @@ namespace umbraco.cms.businesslogic.member
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
public static MemberType MakeNew(User u, string Text)
|
||||
{
|
||||
var alias = helpers.Casing.SafeAliasWithForcingCheck(Text);
|
||||
//special case, if it stars with an underscore, we have to re-add it for member types
|
||||
if (Text.StartsWith("_")) alias = "_" + alias;
|
||||
var mt = new Umbraco.Core.Models.MemberType(-1)
|
||||
{
|
||||
Level = 1,
|
||||
Name = Text,
|
||||
Icon = "member.gif"
|
||||
Icon = "member.gif",
|
||||
Alias = alias
|
||||
};
|
||||
ApplicationContext.Current.Services.MemberTypeService.Save(mt);
|
||||
var legacy = new MemberType(mt);
|
||||
|
||||
Reference in New Issue
Block a user