public Device Get(User user, int id, IRepositoryModelCache cache = null) { var result = Get(id, cache); if (result == null) { return(null); } if (result.Network == null) { throw new Exception("Network not set"); } if (result.Network.Owner == null) { throw new Exception("Owner not set"); } if (result.Network.Owner.Id != user.Id) { var guest = _guests.Check(result.Network, user); if (!guest) { result = null; } } return(result); }
public static void Copy(this INetworkGuestRepository repository, Network source, Network destination) { var users = repository.Get(source); foreach (var user in users) { if (!repository.Check(destination, user)) { repository.Add(destination, user); } } }