internal static User GetUmbracoUser(IGroupUnit <ISecurityStore> uow, HiveId id, bool userIsOnline) { var user = uow.Repositories .GetEntityByRelationType <User>(FixedRelationTypes.DefaultRelationType, FixedHiveIds.UserVirtualRoot) .SingleOrDefault(x => x.Id.Value == id.Value); //.SingleOrDefault(x => x.Id.ToString(HiveIdFormatStyle.AsUri) == id.ToString(HiveIdFormatStyle.AsUri)); //Had to change this comparison to use values because the Uri portion wont work with the membership wrapper provider because the //underlying membership providers dont know anything about a URI, therefore teh wrapper only passes in the value portion of the HiveId. SD. 28/11/2011 if (user == null) { return(null); } if (userIsOnline) { user.LastActivityDate = DateTime.UtcNow; uow.Repositories.AddOrUpdate(user); uow.Complete(); } return(user); }
internal static User GetUmbracoUser(IUmbracoApplicationContext appContext, IGroupUnit <ISecurityStore> uow, string username, bool userIsOnline) { // TODO: Enable type of extension method GetEntityByRelationType to be passed all the way to the provider // so that it can use the typemappers collection to map back to a User // APN: I changed SingleOrDefault to FirstOrDefault to guard against YSODs if somehow a duplicate user gets into the store [31/Jan] var userEntity = uow.Repositories .GetEntityByRelationType <TypedEntity>( FixedRelationTypes.DefaultRelationType, FixedHiveIds.UserVirtualRoot) .FirstOrDefault(x => x.Attribute <string>(UserSchema.UsernameAlias) == username); if (userEntity == null) { return(null); } var user = new User(); user.SetupFromEntity(userEntity); if (userIsOnline) { user.LastActivityDate = DateTime.UtcNow; uow.Repositories.AddOrUpdate(user); uow.Complete(); } return(user); }
internal static User GetUmbracoUser(IGroupUnit<ISecurityStore> uow, HiveId id, bool userIsOnline) { var user = uow.Repositories .GetEntityByRelationType<User>(FixedRelationTypes.DefaultRelationType, FixedHiveIds.UserVirtualRoot) .SingleOrDefault(x => x.Id.Value == id.Value); //.SingleOrDefault(x => x.Id.ToString(HiveIdFormatStyle.AsUri) == id.ToString(HiveIdFormatStyle.AsUri)); //Had to change this comparison to use values because the Uri portion wont work with the membership wrapper provider because the //underlying membership providers dont know anything about a URI, therefore teh wrapper only passes in the value portion of the HiveId. SD. 28/11/2011 if (user == null) return null; if (userIsOnline) { user.LastActivityDate = DateTime.UtcNow; uow.Repositories.AddOrUpdate(user); uow.Complete(); } return user; }
internal static User GetUmbracoUser(IUmbracoApplicationContext appContext, IGroupUnit<ISecurityStore> uow, string username, bool userIsOnline) { // TODO: Enable type of extension method GetEntityByRelationType to be passed all the way to the provider // so that it can use the typemappers collection to map back to a User // APN: I changed SingleOrDefault to FirstOrDefault to guard against YSODs if somehow a duplicate user gets into the store [31/Jan] var userEntity = uow.Repositories .GetEntityByRelationType<TypedEntity>( FixedRelationTypes.DefaultRelationType, FixedHiveIds.UserVirtualRoot) .FirstOrDefault(x => x.Attribute<string>(UserSchema.UsernameAlias) == username); if (userEntity == null) return null; var user = new User(); user.SetupFromEntity(userEntity); if (userIsOnline) { user.LastActivityDate = DateTime.UtcNow; uow.Repositories.AddOrUpdate(user); uow.Complete(); } return user; }