@using MrCMS.Web.Apps.Ecommerce.Helpers
@model IList<MrCMS.Web.Apps.Ecommerce.Entities.Discounts.Discount>
@{
    var requestUrl = HttpContext.Current.Request.Url;
    var url = string.Format("{0}{1}{2}", requestUrl.Scheme, Uri.SchemeDelimiter, requestUrl.Authority);
}
<table class="table table-condensed table-striped">
    <thead>
        <tr>
            <th>
                Name
            </th>
            <th>
                Code
            </th>
            <th>
                Url
            </th>
            <th>
                Time period
            </th>
            <th>
                Actions
            </th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @item.Name
                </td>
                <td>
                    @if (item.RequiresCode)
                    {
                        @item.Code
                    }
                    else
                    {
                        <span>Not required</span>
                    }
                </td>
                <td>
                    @if (item.CanBeAppliedFromUrl)
                    {
                        @Html.Label(string.Format("{0}/Discount/{1}", url, item.Code))
                    }
                    else
                    {
                        <span>Cannot be applied from Url</span>
                    }
                </td>
                <td>
                    @item.ValidTimePeriod()
                </td>
                <td>
                    <div class="btn-group">
                        @Html.ActionLink("Edit", "Edit", "Discount", new { id = item.Id }, new { @class = "btn btn-xs btn-default" })
                        @Html.ActionLink("Delete", "Delete", "Discount", new { id = item.Id }, new { @class = "btn btn-xs btn-danger", data_toggle = "fb-modal" })
                    </div>
                </td>
            </tr>
        }
    </tbody>
</table>