Ejemplo n.º 1
0
        ////logo
        ////[ChildActionOnly]
        //public virtual Task<IViewComponentResult> Logo()
        //{
        //    var model = _commonWebService.PrepareLogo();
        //    return Partial(model);
        //}

        ////language
        ////[ChildActionOnly]
        //public virtual Task<IViewComponentResult> LanguageSelector()
        //{
        //    var model = _commonWebService.PrepareLanguageSelector();
        //    if (model.AvailableLanguages.Count == 1)
        //        Content("");

        //    return PartialView(model);
        //}

        ////currency
        ////[ChildActionOnly]
        //public virtual Task<IViewComponentResult> CurrencySelector()
        //{
        //    var model = _commonWebService.PrepareCurrencySelector();
        //    if (model.AvailableCurrencies.Count == 1)
        //        Content("");

        //    return PartialView(model);
        //}
        ////available even when navigation is not allowed
        //[PublicStoreAllowNavigation(true)]
        //public virtual Task<IViewComponentResult> SetCurrency(string customerCurrency, string returnUrl = "")
        //{
        //    _commonWebService.SetCurrency(customerCurrency);

        //    //home page
        //    if (String.IsNullOrEmpty(returnUrl))
        //        returnUrl = Url.RouteUrl("HomePage");

        //    //prevent open redirection attack
        //    if (!Url.IsLocalUrl(returnUrl))
        //        returnUrl = Url.RouteUrl("HomePage");

        //    return Redirect(returnUrl);
        //}

        ////tax type
        ////[ChildActionOnly]
        //public virtual Task<IViewComponentResult> TaxTypeSelector()
        //{
        //    var model = _commonWebService.PrepareTaxTypeSelector();
        //    if (model == null)
        //        return Content("");

        //    return PartialView(model);
        //}
        ////available even when navigation is not allowed
        //[PublicStoreAllowNavigation(true)]
        //public virtual Task<IViewComponentResult> SetTaxType(int customerTaxType, string returnUrl = "")
        //{
        //    _commonWebService.SetTaxType(customerTaxType);

        //    //home page
        //    if (String.IsNullOrEmpty(returnUrl))
        //        returnUrl = Url.RouteUrl("HomePage");

        //    //prevent open redirection attack
        //    if (!Url.IsLocalUrl(returnUrl))
        //        returnUrl = Url.RouteUrl("HomePage");

        //    return Redirect(returnUrl);
        //}

        ////footer
        ////[ChildActionOnly]
        //public virtual Task<IViewComponentResult> JavaScriptDisabledWarning()
        //{
        //    if (!_commonSettings.DisplayJavaScriptDisabledWarning)
        //        return Content("");

        //    return PartialView();
        //}

        //header links
        //[ChildActionOnly]
        public virtual async Task <IViewComponentResult> HeaderLinks()
        {
            var customer = _workContext.CurrentCustomer;

            var unreadMessageCount = _commonWebService.GetUnreadPrivateMessages();
            var unreadMessage      = string.Empty;
            var alertMessage       = string.Empty;

            if (unreadMessageCount > 0)
            {
                unreadMessage = string.Format(_localizationService.GetResource("PrivateMessages.TotalUnread"), unreadMessageCount);

                //notifications here
                if (_forumSettings.ShowAlertForPM &&
                    !customer.GetAttribute <bool>(SystemCustomerAttributeNames.NotifiedAboutNewPrivateMessages, _storeContext.CurrentStore.Id))
                {
                    EngineContextExperimental.Current.Resolve <IGenericAttributeService>().SaveAttribute(customer, SystemCustomerAttributeNames.NotifiedAboutNewPrivateMessages, true, _storeContext.CurrentStore.Id);
                    alertMessage = string.Format(_localizationService.GetResource("PrivateMessages.YouHaveUnreadPM"), unreadMessageCount);
                }
            }

            //standard
            //var model = _commonWebService.PrepareHeaderLinks(customer);
            //model.UnreadPrivateMessages = unreadMessage;
            //model.AlertMessage = alertMessage;

            //async
            var modelAsync = await _commonWebService.PrepareHeaderLinksAsync(customer);

            modelAsync.UnreadPrivateMessages = unreadMessage;
            modelAsync.AlertMessage          = alertMessage;


            return(View("/Views/Shared/Components/Common/HeaderLinks.cshtml", modelAsync));//Views/Shared/Components/Product/
        }