public async Task <Guid> SaveAsync(
            string token,
            string language,
            Guid?id,
            Guid?productAttributeId,
            string name)
        {
            var requestModel = new SaveProductAttributeItemRequestModel
            {
                Id = id,
                ProductAttributeId = productAttributeId,
                Name = name
            };

            var apiRequest = new ApiRequest <SaveProductAttributeItemRequestModel>
            {
                Language        = language,
                Data            = requestModel,
                AccessToken     = token,
                EndpointAddress = $"{this.settings.Value.CatalogUrl}{ApiConstants.Catalog.ProductAttributeItemsApiEndpoint}"
            };

            var response = await this.apiClientService.PostAsync <ApiRequest <SaveProductAttributeItemRequestModel>, SaveProductAttributeItemRequestModel, BaseResponseModel>(apiRequest);

            if (response.IsSuccessStatusCode && response.Data?.Id != null)
            {
                return(response.Data.Id.Value);
            }

            if (!response.IsSuccessStatusCode)
            {
                throw new CustomException(response.Message, (int)response.StatusCode);
            }

            return(default);
Ejemplo n.º 2
0
        public async Task <IActionResult> Index([FromBody] SaveProductAttributeItemRequestModel model)
        {
            var productAttributeId = await this.productAttributeItemsRepository.SaveAsync(
                await HttpContext.GetTokenAsync(ApiExtensionsConstants.TokenName),
                CultureInfo.CurrentUICulture.Name,
                model.Id,
                model.ProductAttributeId,
                model.Name);

            return(this.StatusCode((int)HttpStatusCode.OK, new { Id = productAttributeId, Message = this.productLocalizer.GetString("ProductAttributeItemSavedSuccessfully").Value }));
        }