Esempio n. 1
0
        public IViewComponentResult Invoke()
        {
            var customer = _workContext.CurrentCustomer;
            var model    = _commonViewModelService.PrepareHeaderLinks(customer);

            if (_forumSettings.AllowPrivateMessages)
            {
                var unreadMessageCount = _commonViewModelService.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))
                    {
                        EngineContext.Current.Resolve <IGenericAttributeService>().SaveAttribute(customer, SystemCustomerAttributeNames.NotifiedAboutNewPrivateMessages, true, _storeContext.CurrentStore.Id);
                        alertMessage = string.Format(_localizationService.GetResource("PrivateMessages.YouHaveUnreadPM"), unreadMessageCount);
                    }
                }
                model.UnreadPrivateMessages = unreadMessage;
                model.AlertMessage          = alertMessage;
            }
            return(View(model));
        }
Esempio n. 2
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var model = await Task.Run(() => _commonViewModelService.PrepareHeaderLinks(_workContext.CurrentCustomer));

            return(View(model));
        }