Пример #1
0
        public async Task<IActionResult> UpdateProductTierPrice(string key, [FromBody] ProductTierPriceDto productTierPrice)
        {
            if (productTierPrice == null)
                return NotFound();

            if (!await _permissionService.Authorize(PermissionSystemName.Products))
                return Forbid();

            var product = await _productApiService.GetById(key);
            if (product == null)
            {
                return NotFound();
            }

            var pt = product.TierPrices.Where(x => x.Id == productTierPrice.Id).FirstOrDefault();
            if (pt == null)
                ModelState.AddModelError("", "No product tier price mapping found with the specified id");

            if (ModelState.IsValid)
            {
                await _productApiService.UpdateProductTierPrice(product, productTierPrice);
                return Ok(true);
            }
            return BadRequest(ModelState);
        }