public ActionResult AccountDropdown() { var user = _services.WorkContext.CurrentUser; var unreadMessageCount = GetUnreadPrivateMessages(); var unreadMessage = string.Empty; var alertMessage = string.Empty; if (unreadMessageCount > 0) { unreadMessage = unreadMessageCount.ToString(); //notifications here if (_forumSettings.ShowAlertForPM && !user.GetAttribute <bool>(SystemUserAttributeNames.NotifiedAboutNewPrivateMessages, _services.SiteContext.CurrentSite.Id)) { _genericAttributeService.Value.SaveAttribute(user, SystemUserAttributeNames.NotifiedAboutNewPrivateMessages, true, _services.SiteContext.CurrentSite.Id); alertMessage = T("PrivateMessages.YouHaveUnreadPM", unreadMessageCount); } } var model = new AccountDropdownModel { IsAuthenticated = user.IsRegistered(), DisplayAdminLink = _services.Permissions.Authorize(StandardPermissionProvider.AccessAdminPanel), AllowPrivateMessages = _forumSettings.AllowPrivateMessages, UnreadPrivateMessages = unreadMessage, AlertMessage = alertMessage }; return(PartialView(model)); }
public ActionResult AccountDropdown() { var customer = _services.WorkContext.CurrentCustomer; var unreadMessageCount = GetUnreadPrivateMessages(); var unreadMessage = string.Empty; var alertMessage = string.Empty; if (unreadMessageCount > 0) { unreadMessage = unreadMessageCount.ToString(); //notifications here if (_forumSettings.ShowAlertForPM && !customer.GetAttribute <bool>(SystemCustomerAttributeNames.NotifiedAboutNewPrivateMessages, _services.StoreContext.CurrentStore.Id)) { _genericAttributeService.Value.SaveAttribute(customer, SystemCustomerAttributeNames.NotifiedAboutNewPrivateMessages, true, _services.StoreContext.CurrentStore.Id); alertMessage = T("PrivateMessages.YouHaveUnreadPM", unreadMessageCount); } } var model = new AccountDropdownModel { IsAuthenticated = customer.IsRegistered(), DisplayAdminLink = _services.Permissions.Authorize(StandardPermissionProvider.AccessAdminPanel), DisplayAgentLink = false, //_services.Permissions.Authorize(StandardPermissionProvider.AccessAgentPanel), IsAgent = customer.IsAgent, ShoppingCartEnabled = _services.Permissions.Authorize(StandardPermissionProvider.EnableShoppingCart), //ShoppingCartItems = customer.CountProductsInCart(ShoppingCartType.ShoppingCart, _services.StoreContext.CurrentStore.Id), WishlistEnabled = _services.Permissions.Authorize(StandardPermissionProvider.EnableWishlist), //WishlistItems = customer.CountProductsInCart(ShoppingCartType.Wishlist, _services.StoreContext.CurrentStore.Id), AllowPrivateMessages = _forumSettings.AllowPrivateMessages, UnreadPrivateMessages = unreadMessage, AlertMessage = alertMessage }; return(PartialView(model)); }
public async Task <IViewComponentResult> InvokeAsync() { var customer = Services.WorkContext.CurrentCustomer; // TODO: (mh) (core) PMs must be prepared in Forum Module and links must be inserted into account_dropdown_after. var model = new AccountDropdownModel { IsAuthenticated = customer.IsRegistered(), DisplayAdminLink = await Services.Permissions.AuthorizeAsync(Permissions.System.AccessBackend), ShoppingCartEnabled = await Services.Permissions.AuthorizeAsync(Permissions.Cart.AccessShoppingCart), WishlistEnabled = await Services.Permissions.AuthorizeAsync(Permissions.Cart.AccessWishlist), //ShoppingCartItems = await Services.DbContext.ShoppingCartItems.CountCartItemsAsync(customer, ShoppingCartType.ShoppingCart, Services.StoreContext.CurrentStore.Id), //WishlistItems = await Services.DbContext.ShoppingCartItems.CountCartItemsAsync(customer, ShoppingCartType.Wishlist, Services.StoreContext.CurrentStore.Id) }; model.MenuItems.Add(new MenuItem().ToBuilder() .Action("Info", "Customer") .LinkHtmlAttributes(new { @class = "dropdown-item", rel = "nofollow" }) .Icon("fal fa-user fa-fw") .Text(T("Account.MyAccount")) .AsItem()); if (model.DisplayAdminLink) { model.MenuItems.Add(new MenuItem().ToBuilder() .Url("~/admin") .LinkHtmlAttributes(new { @class = "dropdown-item", rel = "nofollow", target = "_admin" }) .Icon("fal fa-cog fa-fw") .Text(T("Account.Administration")) .AsItem()); } if (model.WishlistEnabled) { model.MenuItems.Add(new MenuItem().ToBuilder() .Route("Wishlist") .LinkHtmlAttributes(new { @class = "dropdown-item" }) .Icon("fal fa-heart fa-fw") .Text(T("Wishlist")) .Badge(model.WishlistItems.ToString(), BadgeStyle.Success) .BadgeHtmlAttributes("class", "wishlist-qty " + (model.WishlistItems > 0 ? "label-success" : "d-none")) .AsItem()); } if (model.ShoppingCartEnabled) { model.MenuItems.Add(new MenuItem().ToBuilder() .Route("ShoppingCart") .LinkHtmlAttributes(new { @class = "dropdown-item", id = "topcartlink" }) .Icon("fal fa-shopping-bag fa-fw") .Text(T("ShoppingCart")) .Badge(model.ShoppingCartItems.ToString(), BadgeStyle.Success) .BadgeHtmlAttributes("class", "cart-qty " + (model.ShoppingCartItems > 0 ? "label-success" : "d-none")) .AsItem()); } model.MenuItems.Add(new MenuItem().ToBuilder().IsGroupHeader(true).AsItem()); model.MenuItems.Add(new MenuItem().ToBuilder() .Route("Logout") .LinkHtmlAttributes(new { @class = "dropdown-item", rel = "nofollow" }) .Icon("fal fa-sign-out-alt fa-fw") .Text(T("Account.Logout")) .AsItem()); return(View(model)); }