@model Category
@using System.Collections.Generic
@using System.Linq
@using MrCMS.Helpers
@using MrCMS.Web.Apps.Ecommerce.Models
@using MrCMS.Web.Apps.Ecommerce.Pages
@using MrCMS.Web.Apps.Ecommerce.Services.Products
@{
    var query = ViewData["query"] as ProductSearchQuery;
    var parentCategories = Model.ActivePages.Skip(1).Where(webpage => webpage is Category).ToList();
    parentCategories.Reverse();
}
@Html.HiddenFor(x => x.Id)
@Html.HiddenFor(x => x.LiveUrlSegment)

<div class="margin-bottom-30">
    <div class="row" id="product-search-container" data-product-search-container="true" data-product-search-scroll-to="#product-search-container">
        <div class="col-sm-3">
            @{ Html.RenderAction("Query", "ProductSearch", new { query });}
        </div>
        <div class="col-sm-9">
            <h1>@Editable(Model, category => category.Name)</h1>
            @if (Model.ShowSubCategories)
            {
                var categories = ViewData["subcategories"] as IList<Category>;
                if (categories != null)
                {
                    foreach (var categoryChunk in categories.Chunk(3))
                    {
                        <div class="row">
                            @foreach (var category in categoryChunk)
                            {
                                Html.RenderPartial("CategoryCard", category);
                            }
                        </div>
                    }
                }
            }

            @{ Html.RenderAction("Results", "ProductSearch", new { query });}
            @Editable(Model, category => category.BodyContent, true)
        </div>
    </div>
</div>

@{
    Html.IncludeScript("~/Apps/Ecommerce/Content/Scripts/jquery.history.js");
    Html.IncludeScript("~/Apps/Ecommerce/Content/Scripts/custom/product-search.js");
}