示例#1
0
        public Response Update(string resourceGroupName, string galleryName, GalleryUpdate gallery, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (galleryName == null)
            {
                throw new ArgumentNullException(nameof(galleryName));
            }
            if (gallery == null)
            {
                throw new ArgumentNullException(nameof(gallery));
            }

            using var message = CreateUpdateRequest(resourceGroupName, galleryName, gallery);
            _pipeline.Send(message, cancellationToken);
            switch (message.Response.Status)
            {
            case 200:
                return(message.Response);

            default:
                throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }
        public async Task <RedirectToPageResult> OnPostSaveGallery()
        {
            GalleryUpdate galleryUpdate = new GalleryUpdate();

            galleryUpdate.Columns     = Helper.Encode(GetRequestParam("attrs"));
            galleryUpdate.Description = GetRequestParam("inputgallerydescription");
            galleryUpdate.Name        = GetRequestParam("inputgalleryname");
            galleryUpdate.GalleryId   = Convert.ToInt32(GetRequestParam("galleryid"));
            galleryUpdate.Active      = GetRequestParam("toggleActive") == "on" ? true : false;
            galleryUpdate.Images      = Helper.Encode(GetRequestParam("images"));

            string description_ids = GetRequestParam("descriptions");

            foreach (var item in description_ids.Split(","))
            {
                galleryUpdate.ImageAttributes.Add(new ImageInsertUpdate()
                {
                    ImageId     = Convert.ToInt32(item.Split('|')[1]),
                    Description = item.Split('|')[0]
                });
            }

            var serializedGalleryForUpdate = JsonSerializer.Serialize(galleryUpdate);

            var httpClient = _httpClientFactory.CreateClient("APIClient");
            var request    = new HttpRequestMessage(HttpMethod.Put, $"/api/gallery");

            request.Content = new StringContent(serializedGalleryForUpdate, System.Text.Encoding.Unicode, "application/json");

            var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();
            return(new RedirectToPageResult("MyGalleries"));
        }
        public IActionResult UpdateGallery([FromBody] GalleryUpdate gallery)
        {
            using TransactionScope scope = new TransactionScope();

            foreach (var itemimage in gallery.ImageAttributes)
            {
                var imageAttribute = _ijpRepository.GetImageAttribute(itemimage.ImageId);
                imageAttribute.Description = itemimage.Description;

                _ijpRepository.UpdateImageAttribute(imageAttribute);
            }
            _ijpRepository.Save();

            IjpGallery galleryupdate = new IjpGallery()
            {
                Active      = gallery.Active,
                Columns     = gallery.Columns,
                Description = gallery.Description,
                GalleryId   = gallery.GalleryId,
                Images      = gallery.Images,
                Name        = gallery.Name
            };

            var galleryEntity = _mapper.Map <Context.IjpGallery>(galleryupdate);

            _ijpRepository.UpdateGallery(galleryEntity);
            _ijpRepository.Save();

            scope.Complete();

            return(NoContent());
        }
        public virtual GalleryUpdateOperation Update(bool waitForCompletion, GalleryUpdate gallery, CancellationToken cancellationToken = default)
        {
            if (gallery == null)
            {
                throw new ArgumentNullException(nameof(gallery));
            }

            using var scope = _galleryClientDiagnostics.CreateScope("Gallery.Update");
            scope.Start();
            try
            {
                var response  = _galleryRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, gallery, cancellationToken);
                var operation = new GalleryUpdateOperation(ArmClient, _galleryClientDiagnostics, Pipeline, _galleryRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, gallery).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#5
0
        public async virtual Task <GalleryUpdateOperation> UpdateAsync(GalleryUpdate gallery, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (gallery == null)
            {
                throw new ArgumentNullException(nameof(gallery));
            }

            using var scope = _clientDiagnostics.CreateScope("Gallery.Update");
            scope.Start();
            try
            {
                var response = await _restClient.UpdateAsync(Id.ResourceGroupName, Id.Name, gallery, cancellationToken).ConfigureAwait(false);

                var operation = new GalleryUpdateOperation(this, _clientDiagnostics, Pipeline, _restClient.CreateUpdateRequest(Id.ResourceGroupName, Id.Name, gallery).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public async Task Update()
        {
            var name    = Recording.GenerateAssetName("testGallery_");
            var gallery = await CreateGalleryAsync(name);

            var description = "This is a gallery for test";
            var update      = new GalleryUpdate()
            {
                Description = description
            };
            var lro = await gallery.UpdateAsync(update);

            Gallery updatedGallery = lro.Value;

            Assert.AreEqual(description, updatedGallery.Data.Description);
        }
示例#7
0
        internal HttpMessage CreateUpdateRequest(string resourceGroupName, string galleryName, GalleryUpdate gallery)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;

            request.Method = RequestMethod.Patch;
            var uri = new RawRequestUriBuilder();

            uri.Reset(endpoint);
            uri.AppendPath("/subscriptions/", false);
            uri.AppendPath(subscriptionId, true);
            uri.AppendPath("/resourceGroups/", false);
            uri.AppendPath(resourceGroupName, true);
            uri.AppendPath("/providers/Microsoft.Compute/galleries/", false);
            uri.AppendPath(galleryName, true);
            uri.AppendQuery("api-version", "2019-12-01", true);
            request.Uri = uri;
            request.Headers.Add("Content-Type", "application/json");
            using var content = new Utf8JsonRequestContent();
            content.JsonWriter.WriteObjectValue(gallery);
            request.Content = content;
            return(message);
        }
        public virtual GalleriesUpdateOperation StartUpdate(string resourceGroupName, string galleryName, GalleryUpdate gallery, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (galleryName == null)
            {
                throw new ArgumentNullException(nameof(galleryName));
            }
            if (gallery == null)
            {
                throw new ArgumentNullException(nameof(gallery));
            }

            using var scope = _clientDiagnostics.CreateScope("GalleriesOperations.StartUpdate");
            scope.Start();
            try
            {
                var originalResponse = RestClient.Update(resourceGroupName, galleryName, gallery, cancellationToken);
                return(new GalleriesUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateUpdateRequest(resourceGroupName, galleryName, gallery).Request, originalResponse));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#9
0
 /// <summary>
 /// Update a Shared Image Gallery.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='galleryName'>
 /// The name of the Shared Image Gallery. The allowed characters are alphabets
 /// and numbers with dots and periods allowed in the middle. The maximum length
 /// is 80 characters.
 /// </param>
 /// <param name='gallery'>
 /// Parameters supplied to the update Shared Image Gallery operation.
 /// </param>
 public static Gallery Update(this IGalleriesOperations operations, string resourceGroupName, string galleryName, GalleryUpdate gallery)
 {
     return(operations.UpdateAsync(resourceGroupName, galleryName, gallery).GetAwaiter().GetResult());
 }
示例#10
0
 /// <summary>
 /// Update a Shared Image Gallery.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='galleryName'>
 /// The name of the Shared Image Gallery. The allowed characters are alphabets
 /// and numbers with dots and periods allowed in the middle. The maximum length
 /// is 80 characters.
 /// </param>
 /// <param name='gallery'>
 /// Parameters supplied to the update Shared Image Gallery operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Gallery> BeginUpdateAsync(this IGalleriesOperations operations, string resourceGroupName, string galleryName, GalleryUpdate gallery, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, galleryName, gallery, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
        public async ValueTask <Response> UpdateAsync(string resourceGroupName, string galleryName, GalleryUpdate gallery, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (galleryName == null)
            {
                throw new ArgumentNullException(nameof(galleryName));
            }
            if (gallery == null)
            {
                throw new ArgumentNullException(nameof(gallery));
            }

            using var message = CreateUpdateRequest(resourceGroupName, galleryName, gallery);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
                return(message.Response);

            default:
                throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }
示例#12
0
        public async virtual Task <ArmOperation <Gallery> > UpdateAsync(bool waitForCompletion, GalleryUpdate gallery, CancellationToken cancellationToken = default)
        {
            if (gallery == null)
            {
                throw new ArgumentNullException(nameof(gallery));
            }

            using var scope = _galleryClientDiagnostics.CreateScope("Gallery.Update");
            scope.Start();
            try
            {
                var response = await _galleryRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, gallery, cancellationToken).ConfigureAwait(false);

                var operation = new ComputeArmOperation <Gallery>(new GalleryOperationSource(Client), _galleryClientDiagnostics, Pipeline, _galleryRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, gallery).Request, response, OperationFinalStateVia.Location);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }