public async Task AddTenantAsync(string userId, string tenantId)
        {
            if (_tenantAccessor.ActiveTenants.Contains(tenantId))
            {
                return;
            }

            var user = await _readRepository.GetByIdAsync(userId);

            var payload = JsonSerializer.Serialize(new
            {
                user_metadata = new
                {
                    campaigns = user.UserMetadata.Campaigns
                                .Append(tenantId)
                }
            });
            var message = new HttpRequestMessage(
                HttpMethod.Patch,
                "/api/v2/users/" + userId
                )
                          .WithJsonContent(payload);

            var response = await _httpClient.SendAsync(message);

            response.EnsureSuccessStatusCode();
        }
        private async Task <SharedWithEntity> ShareWithUserAsync(string id)
        {
            var user = await _userRepository.GetByIdAsync(id);

            return(user.MapOrDefault(u => new SharedWithEntity
            {
                Kind = SharedWithKind.User,
                OwnershipId = id,
                Picture = u.Picture,
                Email = u.Email,
                Name = u.Name
            }));
        }
Esempio n. 3
0
 public async Task <UserResponse> GetByIdAsync(string id) =>
 (await _readRepository.GetByIdAsync(id))
 .MapOrDefault(ToResponse);