// GET /api/productsapi/showoneproduct/3 public ActionResult <ProductsDTO> ShowOneProduct(int id) { // get the correct product from the database ProductModel product = repository.GetByProductId(id); //create a new DTO based on the Product ProductsDTO productsDTO = new ProductsDTO(product.Id, product.Name, product.Price, product.Description); //return the DTO instead of the product return(productsDTO); }
public IActionResult ShowOneProduct(int id) { return(View(repository.GetByProductId(id))); }