Beispiel #1
0
        public void ModifyUri(Guid clientUriId, ClientUriType type, string uri)
        {
            ClientUri.ValidateUri(uri);

            var toModify = _uris.FirstOrDefault(u => u.Id == clientUriId);

            if (null == toModify)
            {
                throw new EntityValidationException("This URI doesn't exist on this client.");
            }

            if (Active && toModify.Type == ClientUriType.Redirect && type != ClientUriType.Redirect &&
                !_uris.Any(u => u.Type == ClientUriType.Redirect && u.Id != clientUriId))
            {
                throw new EntityValidationException("Cannot change the type of this URI, an active client " +
                                                    "must have at least one Redirect URI.");
            }

            var e = new ModifiedClientUriEvent()
            {
                Uri         = uri,
                UriType     = type,
                ClientId    = Id,
                OccurredOn  = DateTime.UtcNow,
                ClientUriId = clientUriId
            };

            _changes.Add(e);
            EventHandler.UriModified(this, e);
        }
Beispiel #2
0
            public static Client UriModified(Client client, ModifiedClientUriEvent e)
            {
                var modified = client._uris.First(u => u.Id == e.ClientUriId);

                modified.Type = e.UriType;
                modified.Uri  = e.Uri;

                return(client);
            }