ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Views/BackInStockSubscription/SubscribePopup.cshtml
@model BackInStockSubscribeModel
@using Grand.Web.Models.Catalog;
@{
    Layout = "";
}
<form asp-route="BackInStockSubscribePopup" method="post" id="back-in-stock-subscription-form">
    <div class="back-in-stock-subscription-page text-center">
        <h1 class="h5">
            @if (Model.AlreadySubscribed)
                {
                @T("BackInStockSubscriptions.AlreadySubscribed")
            }
            else
            {
                @T("BackInStockSubscriptions.PopupTitle")
            }
        </h1>
        @if (!Model.SubscriptionAllowed)
        {
            <div>
                @T("BackInStockSubscriptions.NotAllowed")
            </div>
        }
        else if (!Model.IsCurrentCustomerRegistered)
        {
            <div>
                @T("BackInStockSubscriptions.OnlyRegistered")
            </div>
        }
        else if (!Model.AlreadySubscribed && Model.CurrentNumberOfBackInStockSubscriptions >= Model.MaximumBackInStockSubscriptions)
        {
            <div>
                @string.Format(T("BackInStockSubscriptions.MaxSubscriptions").Text, Model.MaximumBackInStockSubscriptions)
            </div>
        }
        else
        {
            <input type="submit" id="back-in-stock-notify-me" value="@(Model.AlreadySubscribed ? @T("BackInStockSubscriptions.Unsubscribe").Text : @T("BackInStockSubscriptions.NotifyMe").Text)"
                   class="btn btn-success btn-sm notify-me-button" />
                <script>
                        $(document).ready(function () {
                            $('#back-in-stock-subscription-form').submit(function (event) {
                                event.preventDefault();
                                var $form = $(this),
                                    url = $form.attr('action');
                                var posting = $.post(url, $('#back-in-stock-subscription-form').serialize());
                                posting.done(function (result) {
                                    $("#subscribe-modal-form").modal('hide');
                                });
                            });
                    });
                </script>
        }
    </div>
</form>