@using System.Web.Mvc
@using System.Web.Mvc.Html
@using MrCMS.Helpers
@using MrCMS.Web.Apps.Amazon.Helpers
@using MrCMS.Web.Apps.Amazon.Models
@using MrCMS.Web.Apps.Ecommerce.Helpers
@model MrCMS.Paging.IPagedList<MrCMS.Web.Apps.Amazon.Entities.Logs.AmazonLog>
@{
    ViewBag.Title = "Amazon Logs";
}
@using (Html.BeginForm("Index", "Logs", new {id = ""}, FormMethod.Get, new {id = "edit-settings"}))
{
    <fieldset>
        <legend>Amazon Logs 
            <span class="btn-group  display-inline  pull-right">
                @Html.ActionLink("Delete All Logs", "DeleteAllLogs", "Logs", new {id = ""}, new {@class = "btn btn-danger", data_toggle = "fb-modal"})
                <button class="btn btn-primary" type="submit">Filter Logs</button>
            </span>
        </legend>
    </fieldset>

    <div class="form-group">
        @Html.Label("type", "Filter Logs")
        @Html.DropDownList("type", Enum.GetValues(typeof(AmazonLogType)).OfType<AmazonLogType>().BuildSelectItemList(type => type.GetDescription(), type => type.ToString(), type => type.ToString() == Request["type"], "All"), new{@class="form-control"})
    </div>
}


@if (Model.Count == 0)
{
    @:No results.
}
else
{
    <table class="table table-striped table-condensed" style="overflow: scroll">
        <thead>
            <tr>
                <th>Date
                </th>
                 <th>User
                </th>
                 <th>Type
                </th>
                <th>Status
                </th>
                <th>Message
                </th>
                <th>Actions
                </th>
            </tr>
        </thead>
        <tbody>
            @foreach (var entry in Model)
            {
                <tr>
                    <td>
                        @entry.CreatedOn.ToString("dd/MM/yyyy HH:mm:ss")
                    </td>
                     <td>
                        @(entry.User!=null?entry.User.Name:"System")
                    </td>
                    <td>
                        @entry.LogType.GetDescription()
                    </td>
                    <td>
                        @entry.LogStatus.GetDescription()
                    </td>
                    <td>
                        @entry.Message.ToShortString(40)
                    </td>
               
                    <td>
                        @Html.ActionLink("Details", "Details", new {id = entry.Id})
                    </td>
                </tr>
            }
        </tbody>
    </table>
}
@Html.Pager(Model, "Index", i => new { page = i })
