void IManualAuth <K, A> .SetAllowed(Lite <RoleEntity> role, K key, A allowed) { R resource = ToEntity(key); var keyCoercer = coercer.GetCoerceValueManual(key); ManualResourceCache miniCache = new ManualResourceCache(key, resource, merger, keyCoercer); allowed = keyCoercer(role, allowed); if (miniCache.GetAllowed(role).Equals(allowed)) { return; } IQueryable <RT> query = Database.Query <RT>().Where(a => a.Resource == resource && a.Role == role); if (miniCache.GetAllowedBase(role).Equals(allowed)) { if (query.UnsafeDelete() == 0) { throw new InvalidOperationException("Inconsistency in the data"); } } else { if (query.UnsafeUpdate().Set(a => a.Allowed, a => allowed).Execute() == 0) { new RT { Role = role, Resource = resource, Allowed = allowed, } }
void IManualAuth <Type, TypeAllowedAndConditions> .SetAllowed(Lite <RoleEntity> role, Type key, TypeAllowedAndConditions allowed) { TypeEntity resource = TypeLogic.TypeToEntity.GetOrThrow(key); ManualResourceCache miniCache = new ManualResourceCache(resource, merger); if (miniCache.GetAllowed(role).Equals(allowed)) { return; } IQueryable <RuleTypeEntity> query = Database.Query <RuleTypeEntity>().Where(a => a.Resource == resource && a.Role == role); if (miniCache.GetAllowedBase(role).Equals(allowed)) { if (query.UnsafeDelete() == 0) { throw new InvalidOperationException("Inconsistency in the data"); } } else { query.UnsafeDelete(); allowed.ToRuleType(role, resource).Save(); } }
A IManualAuth <K, A> .GetAllowed(Lite <RoleEntity> role, K key) { R resource = ToEntity(key); ManualResourceCache miniCache = new ManualResourceCache(key, resource, merger, coercer.GetCoerceValueManual(key)); return(miniCache.GetAllowed(role)); }
TypeAllowedAndConditions IManualAuth <Type, TypeAllowedAndConditions> .GetAllowed(Lite <RoleEntity> role, Type key) { TypeEntity resource = TypeLogic.TypeToEntity.GetOrThrow(key); ManualResourceCache miniCache = new ManualResourceCache(resource, merger); return(miniCache.GetAllowed(role)); }