@model economy.Models.View<economy.Models.Seasonal.Request, economy.Models.Seasonal.Response>

@{
    ViewData["Title"] = "24절기";
}

<div class="container">
    <h3>24절기</h3>

    @await Html.PartialAsync("NavTab")

    <div class="row mt-3">
        <div class="col align-self-center">
            @((Model?.Response?.Body?.TotalCount ?? 0).ToString("N0")) 개
        </div>
        <div class="col-auto">
            @{
                var years = ViewData["years"] as IEnumerable<int> ?? Enumerable.Empty<int>();
            }
            <select name="year" id="year" class="form-select" form="fSearch">
                @foreach (var year in years)
                {
                    if (year == Model.Request?.Year)
                    {
                        <option value="@year" selected="selected">@year</option>
                    }
                    else
                    {
                        <option value="@year">@year</option>
                    }
                }
            </select>
        </div>
    </div>

    <div class="table-responsive">
        <table id="daySeasonal" class="table table-bordered table-hover">
            <caption class="caption-top">
                
            </caption>
            <thead>
                <tr>
                    <th>번호</th>
                    <th>날짜</th>
                    <th>종류</th>
                    <th>명칭</th>
                    <th>공공기간 휴일 여부</th>
                    <th>한국표준시간</th>
                    <th>태양황경(도)</th>
                </tr>
            </thead>
            <tbody>
                @if (Model.Response.Body != null && Model.Response.Body?.TotalCount > 0)
                {
                    @foreach (var row in Model.Response.Body.Items.ItemList)
                    {
                        <tr>
                            <td>@row.Num</td>
                            <td>@row.LocDate</td>
                            <td>@row.DateKind</td>
                            <td>@row.DateName</td>
                            <td>@row.IsHoliday</td>
                            <td>@row.Kst</td>
                            <td>@row.SunLongitude</td>
                        </tr>
                    }
                }
                else
                {
                    <tr>
                        <td colspan="7">
                            No data.
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>

    <form id="fSearch" method="get" accept-charset="UTF-8" rel="search" autocomplete="off" asp-controller="Day" asp-action="Seasonal"></form>
</div>

@section Scripts {
    <script src="~/js/day.js" asp-append-version="true"></script>
}
@section Styles {
    <link href="~/css/style.css" rel="stylesheet" asp-append-version="true" />
}