@using System.Linq
@using MrCMS.Helpers
@using MrCMS.Paging
@using MrCMS.Web.Apps.Ecommerce.Entities.Discounts
@model MrCMS.Web.Apps.Ecommerce.Areas.Admin.Models.DiscountSearchQuery
@{
    ViewBag.Title = "Discounts";
    var discounts = ViewData["results"] as IPagedList<Discount> ?? PagedList<Discount>.Empty;
}

<h1 class="page-header">
    Discounts
    <span class="btn-group  display-inline  pull-right">
        <a href="@Url.Action("Add", "Discount")" class="btn btn-primary" data-toggle="fb-modal">Add Discount</a>
    </span>
</h1>


@using (Html.BeginForm("Index", "Discount", FormMethod.Get))
{
    <div class="row">
        <div class="col-xs-6">
            @Html.LabelFor(query => query.DiscountCode)
            <div class="form-group">
                @Html.TextBoxFor(query => query.DiscountCode, new { @class = "form-control" })
            </div>
        </div>
        <div class="col-xs-6">
            @Html.LabelFor(query => query.Name)
            <div class="form-group">
                @Html.TextBoxFor(query => query.Name, new { @class = "form-control" })
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-6">
            <div class="form-inline">
                @Html.InlineCheckboxFor(query => query.ShowExpired)
            </div>
        </div>
    </div>
    <br/>
    <div class="row">
        <div class="col-xs-4">
            <input type="submit" class="btn btn-primary btn-success" value="Search" />
        </div>
    </div>
}

<br/>
@if (discounts.Any())
{
    Html.RenderPartial("DiscountList", discounts.ToList());
    @Html.Pager(discounts, "Index", page => new { page })
}
else
{
    @Resource("No discounts available")
}


