Example #1
0
        public virtual async Task <int> CloneClientAsync(ClientCloneDto client)
        {
            var canInsert = await CanInsertClientAsync(client, true);

            if (!canInsert)
            {
                //If it failed you need get original clientid, clientname for view title
                var clientInfo = await ClientRepository.GetClientIdAsync(client.Id);

                client.ClientIdOriginal   = clientInfo.ClientId;
                client.ClientNameOriginal = clientInfo.ClientName;

                throw new UserFriendlyViewException(string.Format(ClientServiceResources.ClientExistsValue().Description, client.ClientId), ClientServiceResources.ClientExistsKey().Description, client);
            }

            var clientEntity = client.ToEntity();

            var clonedClientId = await ClientRepository.CloneClientAsync(clientEntity, client.CloneClientCorsOrigins,
                                                                         client.CloneClientGrantTypes, client.CloneClientIdPRestrictions,
                                                                         client.CloneClientPostLogoutRedirectUris,
                                                                         client.CloneClientScopes, client.CloneClientRedirectUris, client.CloneClientClaims, client.CloneClientProperties);

            await AuditEventLogger.LogEventAsync(new ClientClonedEvent(client));

            return(clonedClientId);
        }
Example #2
0
        public async Task <IActionResult> ClientClone(ClientCloneDto client)
        {
            if (!ModelState.IsValid)
            {
                return(Success(client));
            }

            var newClientId = await _clientService.CloneClientAsync(client);


            return(Success(new { Id = newClientId }));
        }
        public async Task <IActionResult> ClientClone(ClientCloneDto client)
        {
            if (!ModelState.IsValid)
            {
                return(View(client));
            }

            var newClientId = await _clientService.CloneClientAsync(client);

            SuccessNotification(string.Format(_localizer["SuccessClientClone"], client.ClientId), _localizer["SuccessTitle"]);

            return(RedirectToAction(nameof(Client), new { Id = newClientId }));
        }
Example #4
0
        public virtual ClientCloneDto BuildClientCloneViewModel(int id, ClientDto clientDto)
        {
            var client = new ClientCloneDto
            {
                CloneClientCorsOrigins            = true,
                CloneClientGrantTypes             = true,
                CloneClientIdPRestrictions        = true,
                CloneClientPostLogoutRedirectUris = true,
                CloneClientRedirectUris           = true,
                CloneClientScopes     = true,
                CloneClientClaims     = true,
                CloneClientProperties = true,
                ClientIdOriginal      = clientDto.ClientId,
                ClientNameOriginal    = clientDto.ClientName,
                Id = id
            };

            return(client);
        }
 public ClientClonedEvent(ClientCloneDto client)
 {
     Client = client;
 }