Beispiel #1
0
        private async Task UpdateNetworkAccessAsync(NetworkAccessModel networkAccess)
        {
            NetworkAccess entity = await Context.NetworkAccesses.SingleAsync(n => n.Id == networkAccess.Id);

            entity.AccessMode = networkAccess.AccessMode.ToEntity();

            await UpdateUserAccessesAsync(networkAccess.Id, networkAccess.PermittedUsers);

            Context.Attach(entity);
        }
Beispiel #2
0
        private void CreateNetworkAccess(NetworkAccessModel networkAccess)
        {
            var entity = new NetworkAccess
            {
                Id         = networkAccess.Id,
                AccessMode = networkAccess.AccessMode.ToEntity()
            };

            Context.NetworkAccesses.Add(entity);
        }
Beispiel #3
0
        private static bool CanAccess(Guid userId, NetworkAccessModel access, Guid ownerId)
        {
            if (ownerId == userId)
            {
                return(true);
            }

            switch (access.AccessMode)
            {
            case AccessMode.Private:
                return(false);

            case AccessMode.ByPermission:
                return(access.PermittedUsers.Contains(userId));

            case AccessMode.Public:
                return(true);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Beispiel #4
0
 public NetworkAccess(NetworkAccessModel readAccess)
 {
     AccessMode     = readAccess.AccessMode;
     PermittedUsers = readAccess.PermittedUsers;
 }