Exemplo n.º 1
0
        public async Task <object> Create([FromBody] CreateClientDto createClientDto)
        {
            if (!ModelState.IsValid)
            {
                // Tälle tulee parempi vaihtoehto seuraavassa esimerkissä
                return(ModelState);
            }
            // Business ID on vakiona 1 tässä esimerkissä
            var businessId = 1;

            var newClient = new Client()
            {
                City       = createClientDto.City,
                Address    = createClientDto.Address,
                Name       = createClientDto.Name,
                PostCode   = createClientDto.PostCode,
                Email      = createClientDto.Email,
                BusinessId = businessId,
            };

            dbContext.Client.Add(newClient);
            await dbContext.SaveChangesAsync();

            return(newClient);
        }
Exemplo n.º 2
0
        private async Task SynchronizeClientsAsync(AppModel model, SyncOptions options, ISession session)
        {
            var current = await session.Apps.GetClientsAsync(session.App);

            if (options.Delete)
            {
                foreach (var client in current.Items)
                {
                    var generatedClientId = $"{session.App}:{client.Id}";

                    if (model.Clients.ContainsKey(client.Id) || session.ClientId.Equals(generatedClientId))
                    {
                        continue;
                    }

                    await log.DoSafeAsync($"Client '{client.Id}' deleting", async() =>
                    {
                        await session.Apps.DeleteClientAsync(session.App, client.Id);
                    });
                }
            }

            foreach (var(clientId, _) in model.Clients)
            {
                var existing = current.Items.FirstOrDefault(x => x.Id == clientId);

                if (existing != null)
                {
                    continue;
                }

                await log.DoSafeAsync($"Client '{clientId}' creating", async() =>
                {
                    var request = new CreateClientDto {
                        Id = clientId
                    };

                    current = await session.Apps.PostClientAsync(session.App, request);
                });
            }

            foreach (var(clientId, value) in model.Clients)
            {
                var existing = current.Items.FirstOrDefault(x => x.Id == clientId);

                if (existing == null || value.JsonEquals(existing))
                {
                    continue;
                }

                await log.DoSafeAsync($"Client '{clientId}' updating", async() =>
                {
                    var request = new UpdateClientDto {
                        Role = value.Role
                    };

                    await session.Apps.PutClientAsync(session.App, clientId, request);
                });
            }
        }
Exemplo n.º 3
0
        public async Task RegisterClientAsync(CreateClientDto client)
        {
            if (await DbContext.Clients.FirstOrDefaultAsync(c =>
                                                            c.FirstName == client.FirstName &&
                                                            c.LastName == client.LastName &&
                                                            c.Patronymic == client.Patronymic &&
                                                            c.DateOfBirth == client.DateOfBirth) == null)
            {
                var mapped = new Client()
                {
                    LastName       = client.LastName,
                    FirstName      = client.FirstName,
                    Patronymic     = client.Patronymic,
                    DateOfBirth    = client.DateOfBirth,
                    AccountBalance = client.AccountBalance
                };
                await DbContext.Clients.AddAsync(mapped);

                await DbContext.SaveChangesAsync();
            }
            else
            {
                throw new ArgumentException();
            }
        }
Exemplo n.º 4
0
        public async Task Post_Should_Create_Client()
        {
            var toCreateClient = new CreateClientDto()
            {
                ClientType  = _confidentialClientType.Wording,
                Description = "a new client for logged user !",
                Name        = "logged user's client",
                ReturnUrls  = new List <string>()
                {
                    "http://return.com"
                },
                ScopesIds = new List <int>()
                {
                    _scope1.Id,
                    _scope2.Id
                }
            };

            var httpResponseMessage = await _client.PostAsJsonAsync("clients", toCreateClient);

            Assert.AreEqual(HttpStatusCode.Created, httpResponseMessage.StatusCode);
            Assert.IsTrue(httpResponseMessage.Headers.Contains("location"));

            var location = httpResponseMessage.Headers.GetValues("location").Single();

            Assert.IsTrue(location.Length > 0);

            var clientId = Int32.Parse(location.Split('/', StringSplitOptions.RemoveEmptyEntries).Last());

            Client              myNewClient       = null;
            ClientReturnUrl     myClientReturnUrl = null;
            IList <ClientScope> myClientScopes    = null;

            using (var context = new DaOAuthContext(_dbContextOptions))
            {
                myNewClient       = context.Clients.Where(c => c.Id.Equals(clientId)).SingleOrDefault();
                myClientReturnUrl = context.ClientReturnUrls.Where(c => c.ClientId.Equals(clientId)).SingleOrDefault();
                myClientScopes    = context.ClientsScopes.Where(c => c.ClientId.Equals(clientId)).ToList();
            }

            Assert.IsNotNull(myNewClient);
            Assert.AreEqual(toCreateClient.Description, myNewClient.Description);
            Assert.AreEqual(toCreateClient.Name, myNewClient.Name);
            Assert.IsTrue(myNewClient.IsValid);
            Assert.IsTrue(myNewClient.PublicId.Length > 0);
            Assert.IsTrue(myNewClient.ClientSecret.Length > 0);
            Assert.AreEqual(DateTime.Now.Date, myNewClient.CreationDate.Date);

            Assert.IsNotNull(myClientReturnUrl);
            Assert.AreEqual(toCreateClient.ReturnUrls.First(), myClientReturnUrl.ReturnUrl);

            Assert.IsNotNull(myClientScopes);
            Assert.IsTrue(toCreateClient.ScopesIds.Count() > 0);
            Assert.AreEqual(toCreateClient.ScopesIds.Count(), myClientScopes.Count());
            foreach (var scopeId in toCreateClient.ScopesIds)
            {
                Assert.IsTrue(myClientScopes.Select(cs => cs.ScopeId).Contains(scopeId));
            }
        }
Exemplo n.º 5
0
        public IActionResult Post(CreateClientDto infos)
        {
            infos.UserName = User.Identity.Name;
            var createdId  = _service.CreateClient(infos);
            var currentUrl = UriHelper.GetDisplayUrl(Request);

            return(Created($"{currentUrl}/{createdId}", null));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> PostClient(string app, [FromBody] CreateClientDto request)
        {
            var command = request.ToCommand();

            var response = await InvokeCommandAsync(command);

            return(CreatedAtAction(nameof(GetClients), new { app }, response));
        }
        public async Task <IActionResult> Create(CreateClientDto input)
        {
            var newGuid = Guid.NewGuid();
            await _mediatorService.Send(new AddClientCommand(newGuid, input.FirstName, input.LastName,
                                                             input.ContactNumber, input.EmailAddress));

            return(new OkObjectResult(new { newGuid }));
        }
Exemplo n.º 8
0
        public IActionResult Put(long id, [FromBody] CreateClientDto dto)
        {
            var client = _clientService.UpdateClient(id, dto);

            if (client == null)
            {
                return(BadRequest("The client you are trying to update doesn't exist or such phone already exists!"));
            }
            return(NoContent());
        }
Exemplo n.º 9
0
        public async Task <IActionResult> AddClient([FromBody] CreateClientDto input)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelStateErrors));
            }
            var result = await _clientAppService.AddClient(input);

            return(ResultResponse(result, "创建客户端成功"));
        }
Exemplo n.º 10
0
        public async Task <int> CreateNew(int serverId, CreateClientDto client)
        {
            var result = await _http.PostAsJsonAsync($"{_api.Url}/servers/{serverId}/clients", client);

            await result.EnsureSuccess();

            var response = await result.Content.ReadFromJsonAsync <IdResponse>();

            return(response.Id);
        }
Exemplo n.º 11
0
        public async Task Should_manage_clients()
        {
            var clientId    = Guid.NewGuid().ToString();
            var clientName  = "My Client";
            var clientRole1 = "Editor";
            var clientRole2 = "Owner";

            // STEP 1: Create client.
            var createRequest = new CreateClientDto {
                Id = clientId
            };

            var clients_1 = await _.Apps.PostClientAsync(_.AppName, createRequest);

            var client_1 = clients_1.Items.FirstOrDefault(x => x.Id == clientId);

            // Should return client with correct name and id.
            Assert.Equal(clientRole1, client_1.Role);
            Assert.Equal(clientId, client_1.Name);


            // STEP 2: Update client name.
            var updateNameRequest = new UpdateClientDto {
                Name = clientName
            };

            var clients_2 = await _.Apps.PutClientAsync(_.AppName, clientId, updateNameRequest);

            var client_2 = clients_2.Items.FirstOrDefault(x => x.Id == clientId);

            // Should update client name.
            Assert.Equal(clientName, client_2.Name);


            // STEP 3: Update client role.
            var updateRoleRequest = new UpdateClientDto {
                Role = clientRole2
            };

            var clients_3 = await _.Apps.PutClientAsync(_.AppName, clientId, updateRoleRequest);

            var client_3 = clients_3.Items.FirstOrDefault(x => x.Id == clientId);

            // Should update client role.
            Assert.Equal(clientRole2, client_3.Role);


            // STEP 4: Delete client
            var clients_4 = await _.Apps.DeleteClientAsync(_.AppName, clientId);

            var client_4 = clients_4.Items.FirstOrDefault(x => x.Id == clientId);

            // Should not return deleted client.
            Assert.Null(client_4);
        }
Exemplo n.º 12
0
        public IActionResult Post([FromBody] CreateClientDto dto)
        {
            var client = _clientService.AddNewClient(dto);

            if (client == null)
            {
                return(BadRequest("Client with such phone already exists!"));
            }

            return(CreatedAtAction(nameof(GetClient), new { id = client.Id }, client));
        }
Exemplo n.º 13
0
        public async Task <IActionResult> PostAsync(CreateClientDto dto)
        {
            User   user   = _mapper.Map <CreateClientDto, User>(dto);
            Client client = _clientService.CreateClientObject();

            client = await _clientService.AddClient(user, client);

            ReadClientDto readDto = _mapper.Map <ReadClientDto>(client);

            return(Created(nameof(GetAsync), new Response <ReadClientDto>(readDto)));
        }
Exemplo n.º 14
0
        public async Task <bool> AddClient(CreateClientDto client)
        {
            await IsExists(client.ClientId, 0);

            var entity = _mapper.Map <Client>(client);
            await _clientRepository.AddAsync(entity);

            var result = await _clientRepository.SaveChangesAsync() > 0;

            return(result);
        }
        public async Task <IActionResult> PostClient([FromBody] CreateClientDto clientdto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var clientObj = _mapper.Map <Client>(clientdto);
            await _clients.Add(clientObj);

            return(CreatedAtAction("GetClient", new { id = clientObj.Id }, clientObj));
        }
Exemplo n.º 16
0
        public async Task <IActionResult> Post(int id, [FromBody] CreateClientDto client, CancellationToken cancellationToken)
        {
            var command = new CreateClientCommand {
                Client = client, ServerId = id
            };
            var clientId = await Mediator.Send(command, cancellationToken);

            return(new JsonResult(new { id = clientId })
            {
                StatusCode = 201
            });
        }
Exemplo n.º 17
0
        public async Task CreateClientAsync(CreateClientDto createClietnDto)
        {
            var addresses = new List <Address>();
            var contacts  = new List <Contact>();
            var client    = new Client
            {
                UniqueId   = Guid.NewGuid(),
                FirstName  = createClietnDto.FirstName,
                MiddleName = createClietnDto.MiddleName,
                LastName   = createClietnDto.LastName,
                Gender     = createClietnDto.Gender,
            };

            var clientId = await _clientRepository.CreateClientAsync(client);

            if (createClietnDto.AddressesDto != null)
            {
                foreach (var address in createClietnDto.AddressesDto)
                {
                    addresses.Add(new Address
                    {
                        UniqueId      = Guid.NewGuid(),
                        AddressType   = address.AddressType,
                        Line1         = address.Line1,
                        Line2         = address.Line2,
                        Line3         = address.Line3,
                        AreaCode      = address.AreaCode,
                        City          = address.City,
                        StateProvince = address.StateProvince,
                        Country       = address.Country,
                        ClientId      = clientId
                    });
                }
            }

            if (createClietnDto.ContactsDto != null)
            {
                foreach (var contact in createClietnDto.ContactsDto)
                {
                    contacts.Add(new Contact
                    {
                        UniqueId    = Guid.NewGuid(),
                        ContactType = contact.ContactType,
                        Msisdn      = contact.Msisdn,
                        ClientId    = clientId
                    });
                }
            }

            await _addressRepository.CreateAddressesAsync(addresses);

            await _contactRepository.CreateContactsAsync(contacts);
        }
Exemplo n.º 18
0
        private async Task <ClientDto> CreateAsync()
        {
            var createRequest = new CreateClientDto
            {
                Id = id
            };

            var clients = await _.Apps.PostClientAsync(appName, createRequest);

            var client = clients.Items.Find(x => x.Id == id);

            return(client);
        }
        public async Task <int> CreateClientAsync(CreateClientDto createClientDto, CancellationToken ct)
        {
            Client clientsEntity = _mapper.Mapper.Map <Client>(createClientDto);

            _uow.Clients.CreateClient(clientsEntity);

            if (await _uow.SaveChangesAsync(ct) > 0)
            {
                return(clientsEntity.Id);
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 20
0
        public ClientDto AddNewClient(CreateClientDto dto)
        {
            if (PhoneExists(dto.Phone))
            {
                return(null);
            }

            var client = _mapper.Map <Client>(dto);

            _clientRepository.Add(client);
            _clientRepository.Save();

            var result = _mapper.Map <ClientDto>(client);

            return(result);
        }
Exemplo n.º 21
0
        public ClientDto UpdateClient(long id, CreateClientDto dto)
        {
            var client = _clientRepository.Get(id);

            if (client == null || (dto.Phone != client.Phone && PhoneExists(dto.Phone)))
            {
                return(null);
            }

            _mapper.Map(dto, client);

            _clientRepository.Save();

            var result = _mapper.Map <ClientDto>(client);

            return(result);
        }
Exemplo n.º 22
0
        public async Task <IActionResult> Post(CreateClientDto client)
        {
            if (client == null || !ModelState.IsValid)
            {
                return(BadRequest());
            }

            try
            {
                await ClientService.RegisterClientAsync(client);

                return(Ok());
            }
            catch
            {
                return(StatusCode(500, "Error appears during registration"));
            }
        }
Exemplo n.º 23
0
        public async Task CreateClientAsync(CreateClientDto clientDto, CancellationToken ct)
        {
            if (clientDto == null)
            {
                throw new NullReferenceException();
            }

            Client clientEntity = _mapper.Map <Client>(clientDto);

            if (clientEntity == null)
            {
                throw new NullReferenceException();
            }

            _uow.Clients.Add(clientEntity);

            await _uow.SaveChangesAsync(ct);
        }
Exemplo n.º 24
0
        public async Task <IActionResult> CreateClient(CreateClientDto createClientDto)
        {
            try
            {
                createClientDto.UserId = (int)AuthoticateUserId();
                var result = await _clientCashedService.AddAsync(createClientDto);

                if (result.Errors.Any())
                {
                    return(Conflict());
                }
                return(Ok(result.Data));
            }
            catch (Exception ex)
            {
                _logging.WriteExption(ex);
                return(BadRequest());
            }
        }
Exemplo n.º 25
0
        public async Task <ActionResult <ClientDto> > CreateClientAsync(CreateClientDto clientDto)
        {
            Client client = new()
            {
                Id           = Guid.NewGuid(),
                Name         = clientDto.Name,
                Telephone    = clientDto.Telephone,
                Email        = clientDto.Email,
                IsDeleted    = clientDto.IsDeleted,
                Photo        = clientDto.Photo,
                InsertedDate = DateTimeOffset.UtcNow,
                CNP          = clientDto.CNP,
                Adress       = clientDto.Adress,
                Barcode      = random.Next(100000, 999999),
                Comment      = clientDto.Comment
            };
            await repository.CreateClientAsync(client);

            return(CreatedAtAction(nameof(CreateClientAsync), new { id = client.Id }, client.MapToDto()));
        }
Exemplo n.º 26
0
        public async Task Post_Succeeded(
            [Frozen] CreateClientDto createClientDto,
            [Frozen] Client client,
            [Frozen] Client createdClient,
            [Frozen] User user,
            [Frozen] ReadClientDto readClientDto
            )
        {
            //Arrange
            _mapper.Setup(m => m.Map <CreateClientDto, User>(createClientDto)).Returns(user);
            _mapper.Setup(m => m.Map <ReadClientDto>(createdClient)).Returns(readClientDto);
            _clientService.Setup(c => c.CreateClientObject()).Returns(client);
            _clientService.Setup(c => c.AddClient(user, client)).ReturnsAsync(createdClient);

            //Action
            var result = await _clientsController.PostAsync(createClientDto);

            //Assert
            var resultChecked = Assert.IsType <CreatedResult>(result);

            Assert.True(result is CreatedResult);
            Assert.Equal(readClientDto, ((Response <ReadClientDto>)resultChecked.Value).Data);
        }
Exemplo n.º 27
0
        public async Task <IActionResult> CreateAsync([FromBody] CreateClientDto dto)
        {
            if (await _dbContext.Clients.AnyAsync(u => u.ClientId == dto.ClientId))
            {
                return(new ApiResult(ApiResultType.Error, "资源名已经存在"));
            }

            var redirectUris = dto.RedirectUris.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries)
                               .Where(cors => !string.IsNullOrWhiteSpace(cors) && cors.IsUrl()).ToList();

            if (redirectUris.Count == 0)
            {
                return(new ApiResult(ApiResultType.Error, "回调地址不能为空"));
            }

            var allowedCorsOrigins = dto.AllowedCorsOrigins.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries)
                                     .Where(cors => !string.IsNullOrWhiteSpace(cors) && cors.IsUrl()).ToList();

            if (allowedCorsOrigins.Count == 0)
            {
                return(new ApiResult(ApiResultType.Error, "授权范围不能为空"));
            }

            var client = new IdentityServer4.Models.Client();

            switch (dto.AllowedGrantTypes)
            {
            case GrantTypes.Code:
            {
                client.AllowedGrantTypes = Models.GrantTypes.Code;
                break;
            }

            case GrantTypes.Hybrid:
            {
                client.AllowedGrantTypes = Models.GrantTypes.Hybrid;
                break;
            }

            case GrantTypes.Implicit:
            {
                client.AllowedGrantTypes = Models.GrantTypes.Implicit;
                break;
            }

            case GrantTypes.ClientCredentials:
            {
                client.AllowedGrantTypes = Models.GrantTypes.ClientCredentials;
                break;
            }

            case GrantTypes.DeviceFlow:
            {
                client.AllowedGrantTypes = Models.GrantTypes.DeviceFlow;
                break;
            }

            case GrantTypes.ResourceOwnerPassword:
            {
                client.AllowedGrantTypes = Models.GrantTypes.ResourceOwnerPassword;
                break;
            }

            case GrantTypes.CodeAndClientCredentials:
            {
                client.AllowedGrantTypes = Models.GrantTypes.CodeAndClientCredentials;
                break;
            }

            case GrantTypes.HybridAndClientCredentials:
            {
                client.AllowedGrantTypes = Models.GrantTypes.HybridAndClientCredentials;
                break;
            }

            case GrantTypes.ImplicitAndClientCredentials:
            {
                client.AllowedGrantTypes = Models.GrantTypes.ImplicitAndClientCredentials;
                break;
            }

            case GrantTypes.ResourceOwnerPasswordAndClientCredentials:
            {
                client.AllowedGrantTypes = Models.GrantTypes.ResourceOwnerPasswordAndClientCredentials;
                break;
            }
            }

            client.Description   = dto.Description;
            client.Properties    = dto.Properties;
            client.AllowedScopes = dto.AllowedScopes.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
                                   .Where(cors => !string.IsNullOrWhiteSpace(cors)).ToList();
            client.ClientId                     = dto.ClientId;
            client.ClientName                   = dto.ClientName;
            client.ClientUri                    = dto.ClientUri;
            client.ConsentLifetime              = dto.ConsentLifetime;
            client.LogoUri                      = dto.LogoUri;
            client.ProtocolType                 = dto.ProtocolType;
            client.RedirectUris                 = redirectUris;
            client.RequireConsent               = dto.RequireConsent;
            client.RequirePkce                  = dto.RequirePkce;
            client.AccessTokenLifetime          = dto.AccessTokenLifetime;
            client.AccessTokenType              = dto.AccessTokenType;
            client.AllowedCorsOrigins           = allowedCorsOrigins;
            client.AllowOfflineAccess           = dto.AllowOfflineAccess;
            client.AllowRememberConsent         = dto.AllowRememberConsent;
            client.AuthorizationCodeLifetime    = dto.AuthorizationCodeLifetime;
            client.ClientClaimsPrefix           = dto.ClientClaimsPrefix;
            client.DeviceCodeLifetime           = dto.DeviceCodeLifetime;
            client.EnableLocalLogin             = dto.EnableLocalLogin;
            client.IdentityProviderRestrictions = dto.IdentityProviderRestrictions;
            client.IdentityTokenLifetime        = dto.IdentityTokenLifetime;
            client.IncludeJwtId                 = dto.IncludeJwtId;
            client.RefreshTokenExpiration       = dto.RefreshTokenExpiration;
            client.RefreshTokenUsage            = dto.RefreshTokenUsage;
            client.RequireClientSecret          = dto.RequireClientSecret;
            client.UserCodeType                 = dto.UserCodeType;
            client.UserSsoLifetime              = dto.UserSsoLifetime;
            client.AbsoluteRefreshTokenLifetime = dto.AbsoluteRefreshTokenLifetime;
            client.AllowPlainTextPkce           = dto.AllowPlainTextPkce;
            client.AlwaysSendClientClaims       = dto.AlwaysSendClientClaims;
            client.BackChannelLogoutUri         = dto.BackChannelLogoutUri;
            client.FrontChannelLogoutUri        = dto.FrontChannelLogoutUri;
            client.PairWiseSubjectSalt          = dto.PairWiseSubjectSalt;
            client.PostLogoutRedirectUris       = dto.PostLogoutRedirectUris
                                                  .Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries)
                                                  .Where(cors => !string.IsNullOrWhiteSpace(cors) && cors.IsUrl()).ToList();
            client.SlidingRefreshTokenLifetime       = dto.SlidingRefreshTokenLifetime;
            client.AllowAccessTokensViaBrowser       = dto.AllowAccessTokensViaBrowser;
            client.BackChannelLogoutSessionRequired  = dto.BackChannelLogoutSessionRequired;
            client.FrontChannelLogoutSessionRequired = dto.FrontChannelLogoutSessionRequired;
            client.UpdateAccessTokenClaimsOnRefresh  = dto.UpdateAccessTokenClaimsOnRefresh;
            client.AlwaysIncludeUserClaimsInIdToken  = dto.AlwaysIncludeUserClaimsInIdToken;


            await _dbContext.Clients.AddAsync(client.ToEntity());

            await _dbContext.SaveChangesAsync();

            return(ApiResult.Ok);
        }
Exemplo n.º 28
0
 public Task <bool> CreateClientAsync(CreateClientDto ClientDto)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 29
0
        public async Task <IActionResult> Create([FromBody] CreateClientDto createClientDto)
        {
            await _clientService.CreateClientAsync(createClientDto);

            return(Ok());
        }
Exemplo n.º 30
0
        private async Task SynchronizeClientsAsync(AppModel model, SyncOptions options, ISession session)
        {
            var current = await session.Apps.GetClientsAsync(session.App);

            if (options.Delete)
            {
                foreach (var client in current.Items)
                {
                    var generatedClientId = $"{session.App}:{client.Id}";

                    if (model.Clients.ContainsKey(client.Id) || session.ClientId.Equals(generatedClientId, StringComparison.Ordinal))
                    {
                        continue;
                    }

                    await log.DoSafeAsync($"Client '{client.Id}' deleting", async() =>
                    {
                        await session.Apps.DeleteClientAsync(session.App, client.Id);
                    });
                }
            }

            foreach (var(clientId, _) in model.Clients)
            {
                var existing = current.Items.Find(x => x.Id == clientId);

                if (existing != null)
                {
                    continue;
                }

                await log.DoSafeAsync($"Client '{clientId}' creating", async() =>
                {
                    var request = new CreateClientDto {
                        Id = clientId
                    };

                    current = await session.Apps.PostClientAsync(session.App, request);
                });
            }

            foreach (var(clientId, client) in model.Clients)
            {
                var existing = current.Items.Find(x => x.Id == clientId);

                if (existing == null || client.JsonEquals(existing))
                {
                    continue;
                }

                if (!options.UpdateCurrentClient && session.ClientId.Equals(clientId, StringComparison.Ordinal))
                {
                    continue;
                }

                await log.DoSafeAsync($"Client '{clientId}' updating", async() =>
                {
                    var request = client.ToUpdate();

                    await session.Apps.PutClientAsync(session.App, clientId, request);
                });
            }
        }