Files
2025-07-18 14:47:22 +03:30

90 lines
2.9 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using System.Text.Json;
using Wiki.Models;
namespace Wiki.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
List<string> list = new List<string>();
list.Add("harry_potter");
list.Add("hermione_granger");
ViewBag.ListOfNames = list;
return View();
}
public IActionResult Privacy()
{
return View();
}
public IActionResult Person(string name)
{
Character character = new Character();
if (name == "hermione_granger")
{
character.Name = "Hermione Granger";
character.Birthdate = "19 September 1979";
character.Quote = "“Stop, stop, stop! Youre going to take someones eye out. Besides, youre saying it wrong. Its leviosa, not leviosar!”";
character.ImageName = "hermione_granger.png";
}
else if (name == "harry_potter")
{
character.Name = "Harry Potter";
character.Birthdate = "31 July 1980";
character.Quote = "\"Ill be in my bedroom, making no noise and pretending Im not there.\"";
character.ImageName = "harry_potter.png";
}
else
{
return NotFound();
}
return View(character);
}
public IActionResult Person2(string id)
{
Character character = new Character();
if (id == "harry_potter")
{
character.Name = "Harry Potter";
character.Birthdate = "31 July 1980";
character.Quote = "\"Ill be in my bedroom, making no noise and pretending Im not there.\"";
character.ImageName = "harry_potter.png";
}
else if (id == "hermione_granger")
{
character.Name = "Hermione Granger";
character.Birthdate = "19 September 1979";
character.Quote = "“Stop, stop, stop! Youre going to take someones eye out. Besides, youre saying it wrong. Its leviosa, not leviosar!”";
character.ImageName = "hermione_granger.png";
}
return View(character);
}
public string Test()
{
return "Test2";
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}