You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Index.cshtml 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. @using Karsha_Site.Application.Services.Products.Queries.GetCategories;
  2. @model List<CategoriesDto>
  3. @{
  4. ViewData["Title"] = "Index";
  5. Layout = "~/Areas/Admin/Views/Shared/_Adminlayout.cshtml";
  6. }
  7. <div class="content container-fluid">
  8. <!-- Page Header -->
  9. <div class="page-header">
  10. <div class="row">
  11. <div class="col-sm-11 col-auto">
  12. <ul class="breadcrumb">
  13. <li class="breadcrumb-item"><a href="index.html">داشبورد</a></li>
  14. <li class="breadcrumb-item active">لیست گروه محصولات</li>
  15. </ul>
  16. </div>
  17. </div>
  18. </div>
  19. <!-- /Page Header -->
  20. <div class="row">
  21. <div class="col-sm-12">
  22. <div class="card">
  23. <div class="card-body">
  24. <div class="table-responsive">
  25. <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper dt-bootstrap4 no-footer">
  26. <div ><div class="col-sm-12 col-md-6"><div class="dataTables_length" id="DataTables_Table_0_length"><label>Show <select name="DataTables_Table_0_length" aria-controls="DataTables_Table_0" class="custom-select custom-select-sm form-control form-control-sm"><option value="10">10</option><option value="25">25</option><option value="50">50</option><option value="100">100</option></select> entries</label></div></div><div class="col-sm-12 col-md-6"></div></div><div >
  27. <div class="col-sm-12">
  28. <table class="datatable table table-hover table-center mb-0 dataTable no-footer" id="DataTables_Table_0" role="grid" aria-describedby="DataTables_Table_0_info">
  29. <thead>
  30. <tr >
  31. <th class="sorting_asc" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-sort="ascending" aria-label="عکس گروه محصول: activate to sort column descending">عکس گروه محصول</th>
  32. <th class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="نام گروه : activate to sort column ascending">نام گروه </th>
  33. <th class="text-right" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="عملیات: activate to sort column ascending">عملیات</th>
  34. </tr>
  35. </thead>
  36. <tbody>
  37. @{
  38. var i = 0;
  39. string classNmae = "odd";
  40. }
  41. @foreach (var item in Model)
  42. {
  43. i++;
  44. if (i % 2 == 0)
  45. {
  46. classNmae = "even";
  47. }
  48. else
  49. {
  50. classNmae = "odd";
  51. }
  52. <tr class="@classNmae">
  53. <td>
  54. <h2 class="table-avatar avatar avatar-lg ml-4">
  55. <img class="avatar-img" src="~/@item.Image" alt="@item.Title" >
  56. </h2>
  57. </td>
  58. <td>
  59. @*@{
  60. string parent = item.Parent != null ? item.Parent.Title : "-";
  61. }*@
  62. <text> @item.Title </text>
  63. </td>
  64. <td>
  65. <a class="btn btn-sm bg-danger-light" onclick="DeleteCategory('@item.ID')">
  66. <i class="fe fe-trash"></i> حذف
  67. </a>
  68. @*@if (item.Parent == null)
  69. {
  70. <a href="~/admin/categories/addnewcategory?ParentId=@item.ID" class="btn btn-success">افزودن فرزند</a>
  71. }
  72. @if (item.HasChild == true)
  73. {
  74. <a href="~/admin/categories/index?ParentId=@item.ID" class="btn btn-info">مشاهده لیست فرزند ها </a>
  75. }
  76. else
  77. {
  78. <a class="btn btn-sm bg-danger-light" onclick="DeleteCategory('@item.ID')">
  79. <i class="fe fe-trash"></i> حذف
  80. </a>
  81. }*@
  82. </td>
  83. </tr>
  84. }
  85. </tbody>
  86. </table>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. @section Scripts
  97. {
  98. <link href="~/Sweetalert2/sweetalert2.min.css" rel="stylesheet" />
  99. <script src="~/Sweetalert2/sweetalert2.min.js"></script>
  100. <script>
  101. function DeleteCategory(CategoryId) {
  102. swal.fire({
  103. title: 'حذف گروه محصول',
  104. text: "کاربر گرامی از حذف گروه مطمئن هستید؟",
  105. icon: 'warning',
  106. showCancelButton: true,
  107. confirmButtonColor: '#d33',
  108. cancelButtonColor: '#7cacbe',
  109. confirmButtonText: 'بله ، گروه حذف شود',
  110. cancelButtonText: 'خیر'
  111. }).then((result) => {
  112. if (result.value) {
  113. var postData = {
  114. 'CategoryId': CategoryId,
  115. };
  116. $.ajax({
  117. contentType: 'application/x-www-form-urlencoded',
  118. dataType: 'json',
  119. type: "POST",
  120. url: "Delete",
  121. data: postData,
  122. success: function (data) {
  123. if (data.isSuccess == true) {
  124. swal.fire(
  125. 'موفق!',
  126. data.message,
  127. 'success'
  128. ).then(function (isConfirm) {
  129. location.reload();
  130. });
  131. }
  132. else {
  133. swal.fire(
  134. 'هشدار!',
  135. data.message,
  136. 'warning'
  137. );
  138. }
  139. },
  140. error: function (request, status, error) {
  141. alert(request.responseText);
  142. }
  143. });
  144. }
  145. })
  146. }
  147. </script>
  148. }