@model HPlusSports.Models.ShoppingCart

@{
    ViewBag.Title = "My Cart";
}

@if (TempData.SuccessMessage() != null)
{
    <div class="alert alert-success alert-dismissible" role="alert">
      <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      @TempData.SuccessMessage()
    </div>
}

<div class="cart row">

  <div>
    <hr />
    <table class="table">
      <thead>
        <tr>
          <th class="col-md-1">
          </th>
          <th class="col-md-6">
            Product
          </th>
          <th class="col-md-1">
            Quantity
          </th>
          <th class="col-md-2">
            Price
          </th>
          <th class="col-md-2">
            Subtotal
          </th>
        </tr>
      </thead>
      <tbody>
        @foreach (var item in Model.Items)
        {
            <tr class="text-middle">
              <td>
                <a href="@Url.Action("Remove", "Cart", new { id = item.Id })">
                  <i class="glyphicon glyphicon-remove text-danger"></i>
                </a>
              </td>
              <td>
                <a href="@Url.Action("Product", "Products", new { id = item.SKU })">
                  <img class="product-image img-thumbnail" src="@Url.Action("Product", "Images", new { id = item.SKU })" />
                  <span>@item.Name</span>
                </a>
              </td>
              <td>
                <a href="@Url.Action("Add", "Cart", new { item.SKU, quantity = -1 })">
                  <i class="glyphicon glyphicon-minus"></i>
                </a>
                @item.Quantity
                <a href="@Url.Action("Add", "Cart", new { item.SKU })">
                  <i class="glyphicon glyphicon-plus"></i>
                </a>
              </td>
              <td>
                @item.Price.ToString("C")
              </td>
              <td>
                @item.Total.ToString("C")
              </td>
            </tr>
        }
      </tbody>
      <tfoot>
        <tr class="text-primary">
          <td colspan="4" class="text-right">
            Subtotal
          </td>
          <td>
            @Model.Subtotal.ToString("C")
          </td>
        </tr>
        <tr class="text-muted">
          <td colspan="4" class="text-right">
            Tax
          </td>
          <td>
            @Model.Tax.ToString("C")
          </td>
        </tr>
        <tr class="text-muted">
          <td colspan="4" class="text-right">
            Shipping
          </td>
          <td>
            @Model.Shipping.ToString("C")
          </td>
        </tr>
        <tr class="text-primary text-large">
          <th colspan="4" class="text-right">
            Total
          </th>
          <th>
            @Model.Total.ToString("C")
          </th>
        </tr>
      </tfoot>
    </table>
  </div>

</div>
