public void RemoveUri(Guid clientUriId) { var toRemove = _uris.FirstOrDefault(u => u.Id == clientUriId); if (null == toRemove) { throw new EntityValidationException("This URI doesn't exist on this client."); } if (Active && !_uris.Any(uri => uri.Type == ClientUriType.Redirect && uri.Id != clientUriId)) { throw new EntityValidationException("Cannot remove this URI, an active client must have at " + "least one Redirect URI."); } var e = new RemovedClientUriEvent() { ClientUriId = clientUriId, ClientId = Id, OccurredOn = DateTime.UtcNow }; _changes.Add(e); EventHandler.UriRemoved(this, e); }
public static Client UriRemoved(Client client, RemovedClientUriEvent e) { client._uris.RemoveAll(u => u.Id == e.ClientUriId); return(client); }