[HttpHead] //HttpHead: for testing Head method public async Task <ActionResult <IEnumerable <ProductColorDto> > > GetProductColors(int productid) { var productcolors = await _productColorService.GetProductColorsByIdAsync(productid, null); if (!productcolors.Any()) { return(NotFound()); } var productImages = await _productImagesService.GetProductImages(productid, null); var productcolorDtos = _mapper.Map <IEnumerable <ProductColorDto> >(productcolors); var productImagesDtos = _mapper.Map <IEnumerable <ProductImageDto> >(productImages); foreach (var productcolorDto in productcolorDtos) { productcolorDto.ProductImageDtos = productImagesDtos.Where(pi => pi.ColorId == productcolorDto.ColorId).ToList(); } return(Ok(productcolorDtos)); }
public async Task <ActionResult <IEnumerable <ProductImageDto> > > GetProductImages(int productid) { var productImages = await _productImagesService.GetProductImages(productid, null); if (!productImages.Any()) { return(NotFound()); } var productImageDtos = _mapper.Map <ProductImageDto>(productImages); return(Ok(productImageDtos)); }