59 lines
1.3 KiB
C#
59 lines
1.3 KiB
C#
using System.Diagnostics;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using TechMarket.Models;
|
|
|
|
namespace TechMarket.Controllers;
|
|
|
|
public class HomeController : Controller
|
|
{
|
|
public IActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[Route("catalog")]
|
|
public IActionResult Catalog()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[Route("about")]
|
|
public IActionResult About()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[Route("contacts")]
|
|
public IActionResult Contacts()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("contacts")]
|
|
public IActionResult Contacts(ContactViewModel model)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return View(model);
|
|
}
|
|
|
|
TempData["Success"] = "Спасибо, " + model.Name + "! Ваше сообщение принято, мы скоро ответим";
|
|
|
|
return RedirectToAction(nameof(Contacts));
|
|
}
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
public IActionResult Error()
|
|
{
|
|
if (HttpContext.Response.StatusCode == 404)
|
|
{
|
|
return View("NotFound");
|
|
}
|
|
|
|
return View(new ErrorViewModel
|
|
{
|
|
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
|
|
});
|
|
}
|
|
} |