Index.cshtml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. @using bitforum.Helpers;
  2. @{
  3. ViewData["Title"] = "배너 관리";
  4. var bannerPositions = ViewBag.BannerPositions as List<bitforum.Models.Page.Banner.BannerPosition>;
  5. var bannerItems = ViewBag.BannerItems as List<bitforum.Models.Page.Banner.BannerItem>;
  6. var total = (ViewBag.Total ?? 0).ToString("N0");
  7. var pagination = ViewBag.Pagination as bitforum.Models.Pagination;
  8. }
  9. <partial name="~/Views/Page/Banner/_Navbar.cshtml" />
  10. <div class="container-fluid">
  11. <h3>@ViewData["Title"]</h3>
  12. <hr />
  13. <partial name="_StatusMessage" />
  14. <div class="row g-2 mb-2">
  15. <div class="col">
  16. <select name="position_id" id="positionID" class="form-select w-auto">
  17. <option value="">선택하세요.</option>
  18. @foreach (var row in bannerPositions)
  19. {
  20. <option value="@row.ID" selected="@(row.ID == ViewBag.PositionID ? "selected" : null)">@row.Subject (@row.BannerItem.Count)</option>
  21. }
  22. </select>
  23. </div>
  24. </div>
  25. <div class="row g-2 align-items-end">
  26. <div class="col">
  27. Total : @total
  28. </div>
  29. <div class="col text-end">
  30. <button type="button" id="btnListDelete" class="btn btn-sm btn-danger" form="fAdminList" data-action="/Page/Banner/Item/Delete">삭제</button>
  31. <a href="/Page/Banner/Item/Write" class="btn btn-sm btn-success">추가</a>
  32. </div>
  33. </div>
  34. <form name="f_admin_list" id="fAdminList" method="post" accept-charset="utf-8" autocomplete="off"></form>
  35. <div class="table-responsive">
  36. <table class="table table-striped table-bordered table-hover mt-3">
  37. <colgroup>
  38. <col width="2%" />
  39. <col width="5%" />
  40. <col width="*" />
  41. <col width="30%" />
  42. <col width="*" />
  43. <col width="*" />
  44. <col width="*" />
  45. <col width="*" />
  46. <col width="*" />
  47. <col width="*" />
  48. </colgroup>
  49. <thead>
  50. <tr>
  51. <th><input type="checkbox" id="checkedAll" class="form-check-input" value="1" form="fAdminList" /></th>
  52. <th>ID</th>
  53. <th>이미지</th>
  54. <th>제목</th>
  55. <th>순서</th>
  56. <th>사용</th>
  57. <th>조회 수</th>
  58. <th>등록일시</th>
  59. <th>수정일시</th>
  60. <th>비고</th>
  61. </tr>
  62. </thead>
  63. <tbody>
  64. @if (bannerItems == null || !bannerItems.Any())
  65. {
  66. <tr>
  67. <td colspan="10">No Data.</td>
  68. </tr>
  69. }
  70. else
  71. {
  72. @foreach (var row in bannerItems)
  73. {
  74. <tr>
  75. <td>
  76. <input type="checkbox" name="ids[]" class="form-check-input list-check-box" value="@row.ID" form="fAdminList" />
  77. </td>
  78. <td>@row.ID</td>
  79. <td>
  80. @if (row.Image is not null && row.Image != string.Empty)
  81. {
  82. <img src="@Url.Content(row.Image)" class="img-fluid img-thumbnail" alt="@row.Subject" />
  83. }
  84. else
  85. {
  86. <text>-</text>
  87. }
  88. </td>
  89. <td>
  90. <span class="badge text-bg-secondary">[@row.BannerPosition.Subject]</span>
  91. <strong>@row.Subject</strong><br/>
  92. <small>
  93. 사용 기한:
  94. @if (row.StartAt != null && row.EndAt != null)
  95. {
  96. <text>@row.StartAt.GetDateAt() ~ @row.EndAt.GetDateAt()</text>
  97. } @if (row.StartAt != null && row.EndAt is null)
  98. {
  99. <text>@row.StartAt.GetDateAt() ~</text>
  100. } @if (row.StartAt is null && row.EndAt != null)
  101. {
  102. <text>~ @row.EndAt.GetDateAt()</text>
  103. }
  104. else
  105. {
  106. <text>[무기한]</text>
  107. }
  108. </small><br/>
  109. <small>크기:@row.Width x @row.Height</small>
  110. </td>
  111. <td>@row.Order</td>
  112. <td>@(row.IsActive ? "Y" : "N")</td>
  113. <td>@row.Views</td>
  114. <td>@row.CreatedAt.GetDateAt()</td>
  115. <td>@row.UpdatedAt.GetDateAt()</td>
  116. <td>
  117. <div class="d-grid gap-2 d-md-block">
  118. <a href="/Page/Banner/Item/@row.ID/Edit" class="btn btn-sm btn-outline-info">수정</a>
  119. <a href="/Page/Banner/Item/@row.ID/Delete" class="btn btn-sm btn-outline-danger btn-row-delete">삭제</a>
  120. </div>
  121. </td>
  122. </tr>
  123. }
  124. }
  125. </tbody>
  126. </table>
  127. <partial name="_Pagination" model="pagination" />
  128. </div>
  129. </div>
  130. <script type="module">
  131. $(document).on("change", "#positionID", function () {
  132. location.href = ("/Page/Banner/Item/" + $(this).val());
  133. });
  134. </script>