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