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

@{
    ViewData["Title"] = "로또 회차별 당첨번호";

    var result = Model.Response;
}

<div class="container">
    <h3>로또 회차별 당첨번호</h3>

    <dl>
        <dd>동행복권에서 제공하는 로또 당첨번호입니다.</dd>
    </dl>

    <div class="row g-2">
        <label for="date" class="col-auto col-form-label">날짜</label>
        <div class="col-auto">
            @{
                int last = Convert.ToInt32(ViewBag.Last); // 명시적 형변환
                int selectedNumber = (int)Model.Request.Number;
            }
            <select name="number" id="number" class="form-select" form="fSearch">
                @for (int number = last; number >= 1; number--)
                {
                    @if (number == selectedNumber)
                    {
                        <option value="@number" selected>@number 회차</option>
                    }
                    else
                    {
                        <option value="@number">@number 회차</option>
                    }
                }
            </select>
        </div>
        <div class="col-auto">
            <button type="submit" class="btn btn-dark" form="fSearch">검색</button>
        </div>
    </div>

    <br/>
    <div class="table-responsive">
        <table class="table table-hover table-bordered table-nowrap">
            <caption class="caption-top">
                <h5>@ViewBag.Last 회 당첨번호</h5>
                (@result.DrawDate 추첨)
            </caption>
            <thead>
                <tr class="text-center">
                    <th colspan="7">당첨번호</th>
                    <th>보너스</th>
                </tr>
            </thead>
            <tbody>
                <tr class="text-center">
                    <td>@result.DrawnNumber1</td>
                    <td>@result.DrawnNumber2</td>
                    <td>@result.DrawnNumber3</td>
                    <td>@result.DrawnNumber4</td>
                    <td>@result.DrawnNumber5</td>
                    <td>@result.DrawnNumber6</td>
                    <td>+</td>
                    <td>@result.BonusNumber</td>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="4" class="text-center">1등 총 당첨금액</td>
                    <td colspan="4" class="text-end">@result.FirstAccumulatedAmount.ToString("N0") 원</td>
                </tr>
                <tr>
                    <td colspan="4" class="text-center">1 게임당 당첨금액</td>
                    <td colspan="4" class="text-end">@result.FirstWinAmount.ToString("N0") 원</td>
                </tr>
                <tr>
                    <td colspan="4" class="text-center">당첨 인원</td>
                    <td colspan="4" class="text-end">@result.FirstPrizeWinnerCount 명</td>
                </tr>
                <tr>
                    <td colspan="4" class="text-center">총 판매금액</td>
                    <td colspan="4" class="text-end">@result.TotalSellAmount.ToString("N0") 원</td>
                </tr>
            </tfoot>
        </table>
        당첨금 지급기한 : 지급개시일로부터 1년 (휴일인 경우 익영업일)
    </div>

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

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