public async Task<IActionResult> UpdateProductCategory(string key, [FromBody] ProductCategoryDto productCategory) { if (productCategory == null) return NotFound(); if (!await _permissionService.Authorize(PermissionSystemName.Products)) return Forbid(); var product = await _productApiService.GetById(key); if (product == null) { return NotFound(); } var pc = product.Categories.Where(x => x.CategoryId == productCategory.CategoryId).FirstOrDefault(); if (pc == null) ModelState.AddModelError("", "No product category mapping found with the specified id"); if (ModelState.IsValid) { await _productApiService.UpdateProductCategory(product, productCategory); return Ok(true); } return BadRequest(ModelState); }