public async Task<IActionResult> UpdateProductSpecification(string key, [FromBody] ProductSpecificationAttributeDto productSpecification) { if (productSpecification == null) return NotFound(); if (!await _permissionService.Authorize(PermissionSystemName.Products)) return Forbid(); var product = await _productApiService.GetById(key); if (product == null) { return NotFound(); } var psa = product.SpecificationAttribute.Where(x => x.Id == productSpecification.Id).FirstOrDefault(); if (psa == null) ModelState.AddModelError("", "No product specification mapping found with the specified id"); if (ModelState.IsValid) { await _productApiService.UpdateProductSpecification(product, productSpecification); return Ok(true); } return BadRequest(ModelState); }