public async Task <ApiResponse> CreateProduct([FromBody] ProductDtos dto) { try { var product = _mapper.Map <Product>(dto); if (product == null) { return(new ApiResponse("Khong co product", product, 400)); } if (product.Id != Guid.Empty) { //add product await _productService.AddAsync(product); var getProduct = await _productService.GetByIdAsync(product.Id); var productVm = _mapper.Map <ProductViewModel>(getProduct); return(new ApiResponse("Add product success", productVm, 201)); } return(new ApiResponse("Error", product.Id, 400)); } catch (Exception ex) { return(new ApiResponse("Can't add product", ex, 400)); } }