дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 17:21:13 +02:00
Razor (.cshtml/.razor) gets syntax highlighting, Roslyn's built-in Razor support with the HTML parts projected to the HTML language server (ordered open/close, a reserved projection URI, scoped capability registrations), and MVC navigation between controller actions and their views, including explicit View("...") names, subfolders and areas.
Closes #615
Co-authored-by: GlitchedPolygons <[email protected]>
44 рядки
1.5 KiB
C#
44 рядки
1.5 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Ticketing.Models;
|
|
|
|
namespace Ticketing.Controllers;
|
|
|
|
public sealed class ShowsController(ILogger<ShowsController> logger) : Controller
|
|
{
|
|
public IActionResult Index(string? q)
|
|
{
|
|
// TODO: page the list once there are more than a handful of shows.
|
|
var pageSize = 20; // Intentional warning: assigned but never used (CS0219).
|
|
var shows = Show.All
|
|
.Where(s => string.IsNullOrWhiteSpace(q) || s.Title.Contains(q, StringComparison.OrdinalIgnoreCase))
|
|
.ToList();
|
|
ViewData["Query"] = q;
|
|
return View(shows);
|
|
}
|
|
|
|
public IActionResult Details(string id)
|
|
{
|
|
var show = Show.Find(id); // Set a breakpoint here (QA: debugger) and inspect `show`.
|
|
return show is null ? RedirectToAction("Index") : View(show);
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult Book(string id) =>
|
|
Show.Find(id) is { } show ? View(new BookingForm(show, new TicketOrder())) : NotFound();
|
|
|
|
[HttpPost, ValidateAntiForgeryToken]
|
|
public IActionResult Book(string id, [Bind(Prefix = "Order")] TicketOrder order)
|
|
{
|
|
if (Show.Find(id) is not { } show)
|
|
{
|
|
return NotFound();
|
|
}
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return View(new BookingForm(show, order));
|
|
}
|
|
logger.LogInformation("{Name} booked {Quantity} seats for {Show}", order.Name, order.Quantity, show.Slug);
|
|
return View("Confirmation", new BookingConfirmation(show, order.Quantity));
|
|
}
|
|
}
|