Exemple #1
0
        public async Task UploadAsync(
            Guid userId,
            string fileName,
            Stream stream,
            CancellationToken cancellationToken = default)
        {
            var user = await profilesApi.GetByIdAsync(userId, cancellationToken);

            var blobContainer = blobClient.GetBlobContainerClient("photos");
            await blobContainer.CreateIfNotExistsAsync(PublicAccessType.BlobContainer, cancellationToken : cancellationToken);

            var blob = blobContainer.GetBlobClient($"{userId.ToString()}/{fileName}");
            await blob.UploadAsync(stream, cancellationToken);

            await profilesApi.UpdateAsync(
                userId,
                new ProfileUpdateViewModel(
                    user.FirstName,
                    user.LastName,
                    user.Gender,
                    user.DateOfBirth,
                    user.City,
                    blob.Uri.ToString()),
                cancellationToken);
        }
        public async Task <DomainResult> UpdateAsync(User user)
        {
            var profile = await profilesApi.GetByIdAsync(user.Id);

            var updateCommand = new ProfileUpdateViewModel(
                profile.FirstName,
                profile.LastName,
                user.Gender,
                user.DateOfBirth,
                profile.City);

            try
            {
                await profilesApi.UpdateAsync(user.Id, updateCommand);

                return(DomainResult.Success());
            }
            catch (Profiles.Client.ApiException ex) when(ex.ErrorCode == (int)HttpStatusCode.BadRequest)
            {
                return(DomainResult.Error("ERROR!!!!"));
            }
        }