using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using System.Diagnostics; using WebVentaCoche.DataBase; using WebVentaCoche.Models; namespace WebVentaCoche.Controllers { public class HomeController : Controller { private readonly ILogger _logger; private readonly ApplicationDbContext _context; public HomeController(ILogger logger, ApplicationDbContext context) { _logger = logger; _context = context; } public IActionResult Index() { return View(); } public IActionResult Privacy() { return View(); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } public async Task ProductsHome() { var products = await _context.Products.ToListAsync(); return View(products); } public async Task ProductsDetailsHome(int id) { var product = await _context.Products.FindAsync(id); if (product == null) { return NotFound(); } return View(product); } } }