Files
hermes/WebApp/Controllers/HomeController.cs
Witkopawel 9151fbb6ab Dodawanie/Usuwanie
Dodawanie/Usuwanie (nie chce tu przeklinać)
2025-04-25 05:19:36 +02:00

33 lines
806 B
C#

using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using WebApp.Data;
using WebApp.Models;
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly ApplicationDbContext _context;
public HomeController(ILogger<HomeController> logger, ApplicationDbContext context)
{
_logger = logger;
_context = context;
}
public IActionResult Index()
{
var events = _context.Events.ToList(); // pobieranie danych z bazy
return View(events); // przekazanie do widoku
}
public IActionResult Privacy()
{
return View();
}
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}