public ActionResult HeaderLinks() { var customer = _workContext.CurrentCustomer; var unreadMessageCount = 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)) { _customerService.SaveCustomerAttribute<bool>(customer, SystemCustomerAttributeNames.NotifiedAboutNewPrivateMessages, true); alertMessage = string.Format(_localizationService.GetResource("PrivateMessages.YouHaveUnreadPM"), unreadMessageCount); } } var model = new HeaderLinksModel() { IsAuthenticated = customer.IsRegistered(), CustomerEmailUsername = customer.IsRegistered() ? (_customerSettings.UsernamesEnabled ? customer.Username : customer.Email) : "", IsCustomerImpersonated = _workContext.OriginalCustomerIfImpersonated != null, DisplayAdminLink = _permissionService.Authorize(StandardPermissionProvider.AccessAdminPanel), ShoppingCartEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart), ShoppingCartItems = customer.ShoppingCartItems.Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart).ToList().GetTotalProducts(), WishlistEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableWishlist), WishlistItems = customer.ShoppingCartItems.Where(sci => sci.ShoppingCartType == ShoppingCartType.Wishlist).ToList().GetTotalProducts(), AllowPrivateMessages = _forumSettings.AllowPrivateMessages, UnreadPrivateMessages = unreadMessage, AlertMessage = alertMessage, }; return PartialView(model); }
public ActionResult HeaderLinks() { var customer = _workContext.CurrentCustomer; var unreadMessageCount = 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)) { _genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.NotifiedAboutNewPrivateMessages, true, _storeContext.CurrentStore.Id); alertMessage = string.Format(_localizationService.GetResource("PrivateMessages.YouHaveUnreadPM"), unreadMessageCount); } } var model = new HeaderLinksModel() { IsAuthenticated = customer.IsRegistered(), CustomerEmailUsername = customer.IsRegistered() ? (_customerSettings.UsernamesEnabled ? customer.Username : customer.Email) : "", ShoppingCartEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart), WishlistEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableWishlist), AllowPrivateMessages = customer.IsRegistered() && _forumSettings.AllowPrivateMessages, UnreadPrivateMessages = unreadMessage, AlertMessage = alertMessage, }; //performance optimization (use "HasShoppingCartItems" property) if (customer.HasShoppingCartItems) { model.ShoppingCartItems = customer.ShoppingCartItems .Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart) .LimitPerStore(_storeContext.CurrentStore.Id) .ToList() .GetTotalProducts(); model.WishlistItems = customer.ShoppingCartItems .Where(sci => sci.ShoppingCartType == ShoppingCartType.Wishlist) .LimitPerStore(_storeContext.CurrentStore.Id) .ToList() .GetTotalProducts(); } return PartialView(model); }
public ActionResult HeaderAuthLinks() { var customer = _workContext.CurrentCustomer; var model = new HeaderLinksModel() { IsAuthenticated = customer.IsRegistered(), CustomerEmailUsername = customer.IsRegistered() ? (_customerSettings.UsernamesEnabled ? customer.Username : customer.Email) : "", }; return PartialView(model); }