58 lines
1.5 KiB
C#
58 lines
1.5 KiB
C#
using System.Diagnostics;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using PaydayFrontend.Models;
|
|
using PaydayFrontend.Services;
|
|
|
|
namespace PaydayFrontend.Controllers;
|
|
|
|
public class HomeController : Controller
|
|
{
|
|
private readonly ILogger<HomeController> _logger;
|
|
private readonly IUniversityService _universityService;
|
|
|
|
public HomeController(ILogger<HomeController> logger, IUniversityService universityService)
|
|
{
|
|
_logger = logger;
|
|
_universityService = universityService;
|
|
}
|
|
|
|
public async Task<IActionResult> Index(string searchString)
|
|
{
|
|
IEnumerable<University> universities = await _universityService.GetAllUniversity();
|
|
|
|
if (!String.IsNullOrEmpty(searchString))
|
|
{
|
|
universities = universities.Where(s => s.Name!.ToLower().Contains(searchString.ToLower()));
|
|
}
|
|
|
|
return View(universities.ToList());
|
|
}
|
|
|
|
[Route("Directions")]
|
|
public IActionResult Directions(long universityId)
|
|
{
|
|
Console.WriteLine(universityId);
|
|
if (universityId == 0)
|
|
return RedirectToAction("Index");
|
|
|
|
|
|
|
|
return View();
|
|
}
|
|
|
|
public IActionResult Credits()
|
|
{
|
|
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 });
|
|
}
|
|
} |