< Summary

Information
Class: AspNetCoreGeneratedDocument.Areas_Studio2_Views_Cart_Index
Assembly: OzonOrdersWeb
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/Areas/Studio2/Views/Cart/Index.cshtml
Line coverage
0%
Covered lines: 0
Uncovered lines: 31
Coverable lines: 31
Total lines: 168
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 68
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ExecuteAsync()0%6480800%
<ExecuteAsync()100%210%
<ExecuteAsync()100%210%
<ExecuteAsync()100%210%
<ExecuteAsync()100%210%
<ExecuteAsync()100%210%
<ExecuteAsync()100%210%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/Areas/Studio2/Views/Cart/Index.cshtml

#LineLine coverage
 1@using OzonDomains.Models
 2@using OzonOrdersWeb.Areas.Studio2.ViewModels.CartViewModels
 3@model List<OzonDomains.Models.OrderCarts.OrderCart>
 4
 5@{
 06    ViewData["Title"] = "Корзины заказов";
 07    int currentPage = ViewBag.CurrentPage as int? ?? 1;
 08    int totalPages = ViewBag.TotalPages;
 9}
 10
 11<div class="d-flex align-items-center justify-content-between mb-3">
 12    <h2 class="mb-0">Корзины заказов</h2>
 13
 14    <form asp-area="Studio2" asp-controller="Cart" asp-action="UpdateCache" method="post" class="mb-0">
 15        <button type="submit" title="Обновить кеш корзины" class="btn btn-link p-0" style="text-decoration: none;">
 16            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor"
 17                 class="bi bi-arrow-clockwise" viewBox="0 0 16 16">
 18                <path fill-rule="evenodd"
 19                      d="M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1
 20                      .908-.417A6 6 0 1 1 8 2z"></path>
 21                <path
 22                    d="M8 4.466V.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284
 23                    0 .384L8.41 4.658A.25.25 0 0 1 8 4.466"></path>
 24            </svg>
 25        </button>
 26    </form>
 27</div>
 28
 29
 30<table class="table table-striped">
 31    <thead>
 32    <partial name="_StandartOrderTableHead" />
 33    <tbody>
 034    @foreach (var cart in Model)
 35    {
 36        <tr>
 37            <td colspan="15" class="bg-light text-dark">
 38                <div class="d-flex justify-content-between align-items-center px-2 py-1">
 39                    <div class="text-nowrap">
 040                        <strong>ID:</strong> @cart.Id &nbsp;  &nbsp;
 041                        <strong>Провайдер:</strong> @cart.Provider &nbsp;  &nbsp;
 042                        <strong>Создан:</strong> @cart.CreatedAt.ToString("HH:mm dd.MM.yyyy")
 43                    </div>
 44                    <div class="text-nowrap">
 45                        <a href="@Url.Action("ViewSummary", "OrderSummary", new { area = "Studio2", cartId = cart.Id })"
 46                           target="_blank"
 47                           class="text-primary text-decoration-none">
 48                            Посмотреть сводку заказа
 49                        </a>
 50                    </div>
 51                </div>
 52            </td>
 53        </tr>
 054        @foreach (var item in cart.OrderItems)
 55        {
 056            @if (item.StudioOrder != null)
 57            {
 058                var rowModel = new CartViewModel
 059                {
 060                    Order = item.StudioOrder,
 061                    Id = item.Id,
 062                    ItemId = item.ItemId,
 063                    OrderItemCode = item.OrderItemCode ?? "",
 064                    ItemStatus = item.ItemStatus?.Name ?? "",
 065                    Quantity = item.Quantity
 066                };
 67                <partial name="_StandartCartOrderRow" model="rowModel" />
 68            }
 69            else
 70            {
 71                <em>—</em>
 72            }
 73        }
 74
 75    }
 76    </tbody>
 77</table>
 78
 79<nav aria-label="Page navigation" class="mt-3">
 80    <ul class="pagination d-flex justify-content-center flex-wrap">
 081        @if (totalPages > 15)
 82        {
 083            if (currentPage <= 8)
 84            {
 085                for (int i = 1; i <= 10; i++)
 86                {
 87                    <li class="page-item @(i == currentPage ? "active" : "")">
 088                        <a class="page-link" asp-action="Index" asp-route-page="@(i)">@i</a>
 89                    </li>
 90                }
 91                <li class="page-item disabled"><span class="page-link">...</span></li>
 92                <li class="page-item">
 093                    <a class="page-link" asp-action="Index" asp-route-page="@(totalPages)">@totalPages</a>
 94                </li>
 95            }
 096            else if (currentPage >= totalPages - 7)
 97            {
 98                <li class="page-item">
 99                    <a class="page-link" asp-action="Index" asp-route-page="1">1</a>
 100                </li>
 101                <li class="page-item disabled"><span class="page-link">...</span></li>
 0102                @for (int i = totalPages - 9; i <= totalPages; i++)
 103                {
 104                    <li class="page-item @(i == currentPage ? "active" : "")">
 0105                        <a class="page-link" asp-action="Index" asp-route-page="@(i)">@i</a>
 106                    </li>
 107                }
 108            }
 109            else
 110            {
 111                <li class="page-item">
 112                    <a class="page-link" asp-action="Index" asp-route-page="1">1</a>
 113                </li>
 114                <li class="page-item disabled"><span class="page-link">...</span></li>
 115
 0116                @for (int i = currentPage - 5; i <= currentPage + 5; i++)
 117                {
 118                    <li class="page-item @(i == currentPage ? "active" : "")">
 0119                        <a class="page-link" asp-action="Index" asp-route-page="@(i)">@i</a>
 120                    </li>
 121                }
 122
 123                <li class="page-item disabled"><span class="page-link">...</span></li>
 124                <li class="page-item">
 0125                    <a class="page-link" asp-action="Index" asp-route-page="@(totalPages)">@totalPages</a>
 126                </li>
 127            }
 128        }
 129        else
 130        {
 0131            for (int i = 1; i <= totalPages; i++)
 132            {
 133                <li class="page-item @(i == currentPage ? "active" : "")">
 0134                    <a class="page-link" asp-action="Index" asp-route-page="@(i)">@i</a>
 135                </li>
 136            }
 137        }
 138
 139    </ul>
 140</nav>
 141
 142
 143
 144@section Scripts {
 145    <script>
 146        document.addEventListener("DOMContentLoaded", function () {
 147            const items = [];
 148
 149            document.querySelectorAll('tr[data-order-item-code]').forEach(row => {
 150                const code = row.getAttribute('data-order-item-code');
 151                const id = row.getAttribute('data-order-item-id');
 152                if (code && id) {
 153                    items.push({ id: id, code: code });
 154                }
 155            });
 156
 157            if (items.length > 0) {
 158                fetch('/Studio2/Tradesoft/UpdateItemsStatus', {
 159                    method: 'POST',
 160                    headers: {
 161                        'Content-Type': 'application/json'
 162                    },
 163                    body: JSON.stringify(items)
 164                });
 165            }
 166        });
 167    </script>
 168}