public async Task<IActionResult> CreateProductSpecification(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("", "Product specification mapping found with the specified id"); if (ModelState.IsValid) { await _productApiService.InsertProductSpecification(product, productSpecification); return Ok(true); } return BadRequest(ModelState); }