public IList <int> GetCategoryIdsByProductId([FromQuery] int productId, [FromQuery] int languageId) { if (productId <= 0) { throw new Exception("Invalid productId in GetCategoryIdsByProductId"); } if (languageId <= 0) { throw new Exception("Invalid languageId in GetCategoryIdsByProductId"); } var categories = _categoryApiService.GetCategoriesByProductId(productId); if (categories == null) { throw new Exception("Categories not found in GetCategoryIdsByProductId"); } var categoriesRootObject = new CategoriesRootObject(); foreach (Category category in categories) { var categoryDto = _dtoHelper.PrepareCategoryDTO(category); categoriesRootObject.Categories.Add(categoryDto); } var result = categoriesRootObject.Categories.Select(c => c.Id).ToList(); return(result); }