Esempio n. 1
0
        public async static Task <CloudBlockBlob> SaveAsync(HttpRequest request, CloudBlobContainer userContainer)
        {
            var principal = await StaticWebAppsAuth.GetClientPrincipalAsync(request);

            var blob = GetBlob(principal, userContainer);

            var requestBody = await new StreamReader(request.Body).ReadToEndAsync();
            var user        = JsonConvert.DeserializeObject <User>(requestBody);

            user.ClientPrincipal = principal;

            await SaveAsync(blob, user);

            return(blob);
        }
Esempio n. 2
0
        public async static Task <CloudBlockBlob> GetBlobAsync(HttpRequest request, CloudBlobContainer userContainer)
        {
            var principal = await StaticWebAppsAuth.GetClientPrincipalAsync(request);

            var blob       = GetBlob(principal, userContainer);
            var blobExists = await blob.ExistsAsync();

            if (!blobExists)
            {
                var user = new User
                {
                    ClientPrincipal = principal
                };

                await SaveAsync(blob, user);
            }

            return(blob);
        }