auto.bus_razor/TicketOffice/Pages/Routes/Index.cshtml

182 lines
9.7 KiB
Plaintext

@page
@using System.Globalization
@model TicketOffice.Pages.Routes.IndexModel
@{
Layout = "~/Pages/Shared/_Layout.cshtml";
ViewData["Title"] = "Пошу маршрутів";
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("uk-UA");
}
<link rel="stylesheet" href="~/css/Routes.css" asp-append-version="true"/>
<div class="wrapper">
<form class="search-block">
<div class="opt">
<div class="station">
<div class="title">
Звідки
</div>
<input type="text" autocomplete="off" asp-for="From">
</div>
<a class="change-dir"></a>
<div class="station">
<div class="title">
Куди
</div>
<input type="text" autocomplete="off" asp-for="To">
</div>
<div class="date">
<div class="title">
Дата відправлення
</div>
<input type="date" value="@Model.Date.ToString("yyyy-MM-dd")" asp-for="Date">
</div>
<div class="search-btn">
<input type="submit" class="search-btn" value="Пошук"/>
</div>
</div>
</form>
@if (Model.Routes != null)
{
<div class="route-list">
<table>
<thead>
<tr>
<th>
№ автобуса
@if (Model.SortString == "increasingNumber")
{
<a class="link-btn-sort" asp-page-handler="SortByNumber" asp-route-SortString="descendingNumber" asp-route-From=@Model.From a in a asp-route-To=@Model.To asp-route-Date=@Model.Date.ToString("yyyy-MM-dd")>🠕</a>
}
else if (Model.SortString == "descendingNumber")
{
<a class="link-btn-sort" asp-page-handler="SortByNumber" asp-route-SortString="increasingNumber" asp-route-From=@Model.From a in a asp-route-To=@Model.To asp-route-Date=@Model.Date.ToString("yyyy-MM-dd")>🠗</a>
}
else
{
<a class="link-btn-sort" asp-page-handler="SortByNumber" asp-route-SortString="increasingNumber" asp-route-From=@Model.From a in a asp-route-To=@Model.To asp-route-Date=@Model.Date.ToString("yyyy-MM-dd")>⮁</a>
}
</th>
<th>
Звідки / Куди
</th>
<th>
Дата
</th>
<th>
<div class="departure">
Відправлення
@if (Model.SortString == "increasingDeparture")
{
<a class="link-btn-sort" asp-page-handler="SortByDeparture" asp-route-SortString="descendingDeparture" asp-route-From=@Model.From a in a asp-route-To=@Model.To asp-route-Date=@Model.Date.ToString("yyyy-MM-dd")>🠕</a>
}
else if (Model.SortString == "descendingDeparture")
{
<a class="link-btn-sort" asp-page-handler="SortByDeparture" asp-route-SortString="increasingDeparture" asp-route-From=@Model.From a in a asp-route-To=@Model.To asp-route-Date=@Model.Date.ToString("yyyy-MM-dd")>🠗</a>
}
else
{
<a class="link-btn-sort" asp-page-handler="SortByDeparture" asp-route-SortString="increasingDeparture" asp-route-From=@Model.From a in a asp-route-To=@Model.To asp-route-Date=@Model.Date.ToString("yyyy-MM-dd")>⮁</a>
}
</div>
<div class="arrival">
Прибуття
@if (Model.SortString == "increasingArrival")
{
<a class="link-btn-sort" asp-page-handler="SortByArrival" asp-route-SortString="descendingArrival" asp-route-From=@Model.From a in a asp-route-To=@Model.To asp-route-Date=@Model.Date.ToString("yyyy-MM-dd")>🠕</a>
}
else if (Model.SortString == "descendingArrival")
{
<a class="link-btn-sort" asp-page-handler="SortByArrival" asp-route-SortString="increasingArrival" asp-route-From=@Model.From a in a asp-route-To=@Model.To asp-route-Date=@Model.Date.ToString("yyyy-MM-dd")>🠗</a>
}
else
{
<a class="link-btn-sort" asp-page-handler="SortByArrival" asp-route-SortString="increasingArrival" asp-route-From=@Model.From a in a asp-route-To=@Model.To asp-route-Date=@Model.Date.ToString("yyyy-MM-dd")>⮁</a>
}
</div>
</th>
<th>
Тривалість
@if (Model.SortString == "increasingDuration")
{
<a class="link-btn-sort" asp-page-handler="SortByDuration" asp-route-SortString="descendingDuration" asp-route-From=@Model.From a in a asp-route-To=@Model.To asp-route-Date=@Model.Date.ToString("yyyy-MM-dd")>🠕</a>
}
else if (Model.SortString == "descendingDuration")
{
<a class="link-btn-sort" asp-page-handler="SortByDuration" asp-route-SortString="increasingDuration" asp-route-From=@Model.From a in a asp-route-To=@Model.To asp-route-Date=@Model.Date.ToString("yyyy-MM-dd")>🠗</a>
}
else
{
<a class="link-btn-sort" asp-page-handler="SortByDuration" asp-route-SortString="increasingDuration" asp-route-From=@Model.From a in a asp-route-To=@Model.To asp-route-Date=@Model.Date.ToString("yyyy-MM-dd")>⮁</a>
}
</th>
<th>
Вільніих місць
</th>
<th>
Дії
</th>
</tr>
</thead>
<tbody>
@foreach (var route in Model.Routes)
{
<tr class="table-row">
<td class="num">
<div>@route.Number</div>
<div class="city-list-btn"><a class="city-list-btn">Маршрут</a></div>
</td>
<td class="city">
<div>@route.Cities.First().Name</div>
<div>@route.Cities.Last().Name</div>
</td>
<td>
<div class="route-date">
<span>
Відправлення
</span>
<span>
@route.Cities.First().ArrivalTime?.ToString("f").Split(",")[0].ToLower(),
@route.Cities.First().DepartureTime?.ToString("dd.MM.yyyy")
</span>
</div>
<div class="route-date">
<span>Прибуття</span>
<span>
@route.Cities.Last().ArrivalTime?.ToString("f").Split(",")[0].ToLower(),
@route.Cities.Last().ArrivalTime?.ToString("dd.MM.yyyy")
</span>
</div>
</td>
<td class="time">
<div>@route.Cities.First().DepartureTime?.ToString("HH:mm")</div>
<div>@route.Cities.Last().ArrivalTime?.ToString("HH:mm")</div>
</td>
<td class="duration">
@{ TimeSpan? duration = route.Cities.Last().ArrivalTime - route.Cities.First().DepartureTime; }
@($"{duration?.TotalHours.ToString().Split(",")[0]}:{duration?.Minutes}")
</td>
<td class="capacity">
@(route.Capacity - route.Tickets.Count)
</td>
<td class="action">
<a class="link-btn-choose">Вибрати</a>
</td>
</tr>
}
</tbody>
</table>
</div>
}
else
{
<div class="search-error">
<p>По заданому Вами напрямку місць немає</p>
</div>
}
</div>