public async Task <ApiResponse> GetProductById(Guid Id) { try { var product = await _productService.GetByIdAsync(Id); if (product == null) { return(new ApiResponse("Khong tim thay san pham nao", Id, 400)); } var productDtos = _mapper.Map <ProductViewModel>(product); return(new ApiResponse("san pham by id ", productDtos, 200)); } catch (Exception ex) { return(new ApiResponse("Loi", ex, 400)); } }
public async Task <ProductViewModel> GetProductById(Guid id) { var product = await _productService.GetByIdAsync(id); return(_mapper.Map <ProductViewModel>(product)); }