@using MrCMS.Helpers
@using MrCMS.Web.Apps.Ecommerce.Pages
@model MrCMS.Paging.IPagedList<Product>
@{ 
    var product = ViewData["product"] as Product;
}

<div id="products"  data-paging-type="async">
     @if (Model.Any())
     {
         <table class="table table-striped table-condensed margin-top-0" style="margin-bottom: 0;">
             <tbody>
                 @foreach (var item in Model)
                 {
                     <tr>
                         <td>@item.Name</td>
                         <td>
                             <div class="pull-right">
                                 <button class="btn btn-success add-product" data-product-id="@item.Id" 
                                         data-parent-product-id="@product.Id" data-page="@(Model.PageCount > 1 ? Model.PageNumber : Model.PageNumber - 1)">Add</button>
                             </div>
                         </td>
                     </tr>
                 }
             </tbody>
         </table>
     }
     else
     {
         <span>No products to add as related.</span>
     }
    @Html.Pager(Model, "AddRelatedProductItems", i => new { page = i, id = product.Id })
</div>