@using System.Drawing
@using MrCMS.Helpers
@using MrCMS.Web.Apps.Ecommerce.Helpers
@using MrCMS.Web.Apps.Ecommerce.Models
@using MrCMS.Web.Apps.Ecommerce.Models.StockAvailability
@using MrCMS.Web.Apps.Ecommerce.Services
@using MrCMS.Web.Apps.Ecommerce.Services.Pricing
@using MrCMS.Web.Apps.Ecommerce.Settings
@using MrCMS.Website
@model MrCMS.Web.Apps.Ecommerce.Entities.Products.ProductVariant
@{
    CanBuyStatus canBuy = ViewData["can-buy-status"] as CanBuyStatus ?? new CannotOrderQuantity(Model, 0);
    var pricingMethod = MrCMSApplication.Get<IProductPricingMethod>();
    var @abstract = Model.Product != null ? Model.Product.ProductAbstract ?? string.Empty : string.Empty;
}
<div class="row" data-wishlist-item="@Model.Id">
    <div class="hidden-xs col-sm-2 col-md-2">
        <a href="@Model.DirectUrl">
            @RenderImage(Model.DisplayImageUrl, new Size { Width = 150, Height = 150 }, null, null, new { @class = "img-responsive" })
        </a>
    </div>
    <div class="col-xs-12 col-sm-7 col-md-8">
        <h3><a href="@Model.DirectUrl">@(!string.IsNullOrWhiteSpace(Model.Name) ? Model.Name : Model.Product.Name)</a></h3>
        <div class="price">
            @pricingMethod.GetPrice(Model).ToCurrencyFormat()
        </div>

        @{
            var displayPreviousPrice = pricingMethod.GetDisplayPreviousPrice(Model);
        }
        @if (displayPreviousPrice != null)
        {
            <div class="margin-bottom-10">
                <span class="previous-price">@(SiteSettings<EcommerceSettings>().PreviousPriceText) <span style="text-decoration: line-through">@displayPreviousPrice.ToCurrencyFormat()</span></span>
            </div>
        }
        <div class="margin-bottom-10">
            @Html.Raw(@abstract.StripHtml().TruncateString(250))
        </div>
    </div>
    <div class="col-xs-12 col-sm-3 col-md-2">
        <div class="text-right">
            @if (canBuy.OK)
            {
                using (Html.BeginForm("Add", "AddToCart", FormMethod.Post))
                {
                    <button class="btn btn-primary btn-block margin-bottom-10">Add to basket</button>
                    @Html.Hidden("ProductVariant.Id", Model.Id)
                    @Html.Hidden("quantity", 1)
                }
            }
            @{ Html.RenderAction("Add", "Wishlist", new { id = Model.Id }); }
        </div>
    </div>
</div>
<hr />
