public virtual HeaderLinksModel PrepareHeaderLinks(Customer customer) { var isRegister = customer.IsRegistered(); var model = new HeaderLinksModel { IsAuthenticated = isRegister, CustomerEmailUsername = isRegister ? (_customerSettings.UsernamesEnabled ? customer.Username : customer.Email) : "", ShoppingCartEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart), WishlistEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableWishlist), AllowPrivateMessages = isRegister && _forumSettings.AllowPrivateMessages, }; //performance optimization (use "HasShoppingCartItems" property) if (customer.HasShoppingCartItems) { model.ShoppingCartItems = customer.ShoppingCartItems .Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart || sci.ShoppingCartType == ShoppingCartType.Auctions) .LimitPerStore(_storeContext.CurrentStore.Id) .Sum(x => x.Quantity); model.WishlistItems = customer.ShoppingCartItems .Where(sci => sci.ShoppingCartType == ShoppingCartType.Wishlist) .LimitPerStore(_storeContext.CurrentStore.Id) .Sum(x => x.Quantity); } return(model); }
public virtual HeaderLinksModel PrepareHeaderLinksModel() { 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(), CustomerName = customer.IsRegistered() ? customer.FormatUserName() : "", AllowPrivateMessages = customer.IsRegistered() && _forumSettings.AllowPrivateMessages, UnreadPrivateMessages = unreadMessage, AlertMessage = alertMessage, }; return(model); }
public ActionResult HeaderLinks() { var customer = _workContext.CurrentCustomer; var model = new HeaderLinksModel { IsAuthenticated = (customer.IsRegistered() || customer.IsAdmin() || customer.IsAgent())?true:false, CustomerEmailUsername = (customer.IsRegistered() || customer.IsAdmin() || customer.IsAgent()) ? customer.Email : "", DisplayAdminLink = (customer.IsAdmin() || customer.IsAgent()), }; if (customer.IsAdmin()) { model.Text = "Admin"; } else if (customer.IsAgent()) { model.Text = "Agent"; } //var model = new HeaderLinksModel //{ // IsAuthenticated = customer.IsRegistered(), // CustomerEmailUsername = customer.IsRegistered() ? customer.Email : "", // DisplayAdminLink = customer.IsAdmin(), //}; return(PartialView(model)); }
public virtual async Task <HeaderLinksModel> PrepareHeaderLinksAsync(Customer customer) { var result = await Task.Run <HeaderLinksModel>(() => { 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, }; //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(model); }); return(result); }
private async Task <HeaderLinksModel> PrepareHeaderLinks() { var isRegister = _workContext.CurrentCustomer.IsRegistered(); var model = new HeaderLinksModel { IsAuthenticated = isRegister, CustomerEmailUsername = isRegister ? (_customerSettings.UsernamesEnabled ? _workContext.CurrentCustomer.Username : _workContext.CurrentCustomer.Email) : "", AllowPrivateMessages = isRegister && _forumSettings.AllowPrivateMessages, }; if (_forumSettings.AllowPrivateMessages) { var unreadMessageCount = await 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 && !_workContext.CurrentCustomer.GetAttributeFromEntity <bool>(SystemCustomerAttributeNames.NotifiedAboutNewPrivateMessages, _storeContext.CurrentStore.Id)) { await HttpContext.RequestServices.GetRequiredService <IGenericAttributeService>().SaveAttribute(_workContext.CurrentCustomer, SystemCustomerAttributeNames.NotifiedAboutNewPrivateMessages, true, _storeContext.CurrentStore.Id); alertMessage = string.Format(_localizationService.GetResource("PrivateMessages.YouHaveUnreadPM"), unreadMessageCount); } } model.UnreadPrivateMessages = unreadMessage; model.AlertMessage = alertMessage; } return(model); }
/// <summary> /// Prepare the header links model /// </summary> /// <returns>Header links model</returns> public virtual HeaderLinksModel PrepareHeaderLinksModel() { 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 && !_genericAttributeService.GetAttribute <bool>(customer, GSCustomerDefaults.NotifiedAboutNewPrivateMessagesAttribute, _storeContext.CurrentStore.Id)) { _genericAttributeService.SaveAttribute(customer, GSCustomerDefaults.NotifiedAboutNewPrivateMessagesAttribute, true, _storeContext.CurrentStore.Id); alertMessage = string.Format(_localizationService.GetResource("PrivateMessages.YouHaveUnreadPM"), unreadMessageCount); } } var model = new HeaderLinksModel { IsAuthenticated = customer.IsRegistered(), CustomerName = customer.IsRegistered() ? _customerService.FormatUserName(customer) : "", ShoppingCartEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart), WishlistEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableWishlist), AllowPrivateMessages = customer.IsRegistered() && _forumSettings.AllowPrivateMessages, UnreadPrivateMessages = unreadMessage, AlertMessage = alertMessage, }; return(model); }
public ActionResult ShoppingCartLink() { var customer = _workContext.CurrentCustomer; var model = new HeaderLinksModel() { ShoppingCartEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart), }; //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 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, }; return(PartialView(model)); }
/* * public virtual LogoModel PrepareLogoModel() * { * var model = new LogoModel * { * StoreName = _storeContext.MevcutSite.GetLocalized(x => x.Adı) * }; * * var cacheKey = string.Format(ModelÖnbellekOlayTüketici.STORE_LOGO_PATH, _storeContext.MevcutSite.Id, _themeContext.MevcutTemaAdı, _webHelper.MevcutBağlantıGüvenli()); * model.LogoPath = _cacheManager.Al(cacheKey, () => * { * var logo = ""; * var logoPictureId = _storeInformationSettings.LogoResimId; * if (logoPictureId > 0) * { * logo = _pictureService.ResimUrlAl(logoPictureId, varsayılanResimGöster: false); * } * if (string.IsNullOrEmpty(logo)) * { * //use default logo * logo = $"{_webHelper.SiteKonumuAl()}Temalar/{_themeContext.MevcutTemaAdı}/Content/images/logo.png"; * } * return logo; * }); * * return model; * } * public virtual LanguageSelectorModel PrepareLanguageSelectorModel() * { * var availableLanguages = _cacheManager.Al(string.Format(ModelÖnbellekOlayTüketici.AVAILABLE_LANGUAGES_MODEL_KEY, _storeContext.MevcutSite.Id), () => * { * var result = _languageService * .GetAllLanguages(storeId: _storeContext.MevcutSite.Id) * .Select(x => new LanguageModel * { * Id = x.Id, * Name = x.Adı, * FlagImageFileName = x.BayrakResmiDosyaAdı, * }) * .ToList(); * return result; * }); * * var model = new LanguageSelectorModel * { * CurrentLanguageId = _workContext.MevcutDil.Id, * AvailableLanguages = availableLanguages, * UseImages = _localizationSettings.UseImagesForLanguageSelection * }; * * return model; * } */ public virtual HeaderLinksModel PrepareHeaderLinksModel() { var customer = _workContext.MevcutKullanıcı; 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.ÖzelMesajUyarısıGöster && !customer.ÖznitelikAl <bool>(SistemKullanıcıÖznitelikAdları.YeniÖzelMesajBilgisi, _storeContext.MevcutSite.Id)) { _genericAttributeService.ÖznitelikKaydet(customer, SistemKullanıcıÖznitelikAdları.YeniÖzelMesajBilgisi, true, _storeContext.MevcutSite.Id); alertMessage = string.Format(_localizationService.GetResource("PrivateMessages.YouHaveUnreadPM"), unreadMessageCount); } } var model = new HeaderLinksModel { Yetkilendirildi = customer.IsRegistered(), KullanıcıAdı = customer.IsRegistered() ? customer.KullanıcıAdıFormatı() : "", SepetEtkin = _permissionService.YetkiVer(StandartİzinSağlayıcı.SepetEtkin), ÖzelMesajlarİzinli = customer.IsRegistered() && _forumSettings.ÖzelMesajEtkin, OkunmamışÖzelMesajlar = unreadMessage, MesajUyarısı = alertMessage, }; //performance optimization (use "HasShoppingCartItems" property) return(model); }
public virtual HeaderLinksModel PrepareHeaderLinksModel() { var customer = _workContext.CurrentCustomer; var model = new HeaderLinksModel { IsAuthenticated = customer.IsRegistered(), CustomerName = customer.IsRegistered() ? customer.FormatUserName() : "", ShoppingCartEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart), WishlistEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableWishlist), }; //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(model); }
public IHttpActionResult HeaderLinks(LoginStatus login) { if (!_customerService.CheckLogin(login.userid, login.logguid)) { return(Ok(new { success = false, msg = "登录超时" })); } var customer = _customerService.GetCustomerById(login.userid); _workContext.CurrentCustomer = customer; 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(Ok(model)); }
private async Task <HeaderLinksModel> PrepareHeaderLinks() { var isRegister = _workContext.CurrentCustomer.IsRegistered(); var model = new HeaderLinksModel { IsAuthenticated = isRegister, CustomerEmailUsername = isRegister ? (_customerSettings.UsernamesEnabled ? _workContext.CurrentCustomer.Username : _workContext.CurrentCustomer.Email) : "", }; return(await Task.FromResult(model)); }
public ActionResult HeaderLinks() { var user = workContext.CurrentUser; var model = new HeaderLinksModel { Username = user.Name }; return(PartialView(model)); }
public ActionResult HeaderLinks() { var model = new HeaderLinksModel(); model.IsAuthenticated = false; if (!string.IsNullOrEmpty(_sessionWrapper.UserName)) { model.IsAuthenticated = true; model.Username = _sessionWrapper.UserName; } 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)); }
/// <summary> /// Prepare the header links model /// </summary> /// <returns>Header links model</returns> public async Task <HeaderLinksModel> PrepareHeaderLinksModel() { var user = _workContext.CurrentUser; var model = new HeaderLinksModel { IsAuthenticated = user.IsRegistered(), UserName = user.IsRegistered() ? await _userService.GetUserFullNameAsync(user) : "", }; return(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(), Money = customer.Money, //CustomerEmailUsername = customer.IsRegistered() ? (_customerSettings.UsernamesEnabled ? customer.Username : customer.Email) : "", CustomerEmailUsername = customer.GetAttribute <string>(SystemCustomerAttributeNames.FirstName) + " " + customer.GetAttribute <string>(SystemCustomerAttributeNames.LastName), 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)); }
/// <summary> /// Prepare the header links model /// </summary> /// <returns>Header links model</returns> public virtual HeaderLinksModel PrepareHeaderLinksModel() { 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, 0)) { _genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.NotifiedAboutNewPrivateMessages, true, 0); alertMessage = string.Format(_localizationService.GetResource("PrivateMessages.YouHaveUnreadPM"), unreadMessageCount); } } var model = new HeaderLinksModel { IsAuthenticated = customer.IsRegistered(), CustomerName = customer.IsRegistered() ? customer.FormatUserName() : "", 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(0) // .ToList() // .GetTotalProducts(); // model.WishlistItems = customer.ShoppingCartItems // .Where(sci => sci.ShoppingCartType == ShoppingCartType.Wishlist) // .LimitPerStore(0) // .ToList() // .GetTotalProducts(); //} return(model); }
/// <summary> /// Prepare the header links model /// </summary> /// <returns> /// A task that represents the asynchronous operation /// The task result contains the header links model /// </returns> public virtual async Task <HeaderLinksModel> PrepareHeaderLinksModelAsync() { var customer = await _workContext.GetCurrentCustomerAsync(); var store = await _storeContext.GetCurrentStoreAsync(); var unreadMessageCount = await GetUnreadPrivateMessagesAsync(); var unreadMessage = string.Empty; var alertMessage = string.Empty; if (unreadMessageCount > 0) { unreadMessage = string.Format(await _localizationService.GetResourceAsync("PrivateMessages.TotalUnread"), unreadMessageCount); //notifications here if (_forumSettings.ShowAlertForPM && !await _genericAttributeService.GetAttributeAsync <bool>(customer, NopCustomerDefaults.NotifiedAboutNewPrivateMessagesAttribute, store.Id)) { await _genericAttributeService.SaveAttributeAsync(customer, NopCustomerDefaults.NotifiedAboutNewPrivateMessagesAttribute, true, store.Id); alertMessage = string.Format(await _localizationService.GetResourceAsync("PrivateMessages.YouHaveUnreadPM"), unreadMessageCount); } } var model = new HeaderLinksModel { RegistrationType = _customerSettings.UserRegistrationType, IsAuthenticated = await _customerService.IsRegisteredAsync(customer), CustomerName = await _customerService.IsRegisteredAsync(customer) ? await _customerService.FormatUsernameAsync(customer) : string.Empty, ShoppingCartEnabled = await _permissionService.AuthorizeAsync(StandardPermissionProvider.EnableShoppingCart), WishlistEnabled = await _permissionService.AuthorizeAsync(StandardPermissionProvider.EnableWishlist), AllowPrivateMessages = await _customerService.IsRegisteredAsync(customer) && _forumSettings.AllowPrivateMessages, UnreadPrivateMessages = unreadMessage, AlertMessage = alertMessage, }; //performance optimization (use "HasShoppingCartItems" property) if (customer.HasShoppingCartItems) { model.ShoppingCartItems = (await _shoppingCartService.GetShoppingCartAsync(customer, ShoppingCartType.ShoppingCart, store.Id)) .Sum(item => item.Quantity); model.WishlistItems = (await _shoppingCartService.GetShoppingCartAsync(customer, ShoppingCartType.Wishlist, store.Id)) .Sum(item => item.Quantity); } return(model); }
/// <summary> /// Prepare the header links model /// </summary> /// <returns>Header links model</returns> public virtual HeaderLinksModel PrepareHeaderLinksModel() { 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 && !_genericAttributeService.GetAttribute <bool>(customer, NopCustomerDefaults.NotifiedAboutNewPrivateMessagesAttribute, _storeContext.CurrentStore.Id)) { _genericAttributeService.SaveAttribute(customer, NopCustomerDefaults.NotifiedAboutNewPrivateMessagesAttribute, true, _storeContext.CurrentStore.Id); alertMessage = string.Format(_localizationService.GetResource("PrivateMessages.YouHaveUnreadPM"), unreadMessageCount); } } var model = new HeaderLinksModel { IsAuthenticated = customer.IsRegistered(), CustomerName = customer.IsRegistered() ? _customerService.FormatUserName(customer) : "", 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) .Sum(item => item.Quantity); model.WishlistItems = customer.ShoppingCartItems .Where(sci => sci.ShoppingCartType == ShoppingCartType.Wishlist) .LimitPerStore(_storeContext.CurrentStore.Id).Count(); } model.CompareProductItems = _compareProductsService.GetComparedProducts().Count(); return(model); }
public ActionResult HeaderLinks() { var user = _workContext.CurrentUser; //var unreadMessageCount = GetUnreadPrivateMessages(); //var unreadMessage = string.Empty; //var alertMessage = string.Empty; //if (unreadMessageCount > 0) //{ // unreadMessage = string.Format(_localizationService.GetResource("PrivateMessages.TotalUnread"), // unreadMessageCount); // alertMessage = string.Format(_localizationService.GetResource("PrivateMessages.YouHaveUnreadPM"), // unreadMessageCount); //} var model = new HeaderLinksModel { // зарегистрирован ли пользователь IsAuthenticated = user.IsRegistered(), CustomerEmailUsername = user.IsRegistered() ? user.Email : "", ShoppingCartEnabled = true, WishlistEnabled = true, AllowPrivateMessages = true, UnreadPrivateMessages = "", AlertMessage = string.Empty }; if (user.HasShoppingCartItems) { model.ShoppingCartItems = user.ShoppingCartItems.Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart) .ToList() .GetTotalProducts(); model.WishlistItems = user.ShoppingCartItems.Where(sci => sci.ShoppingCartType == ShoppingCartType.Wishlist) .ToList() .GetTotalProducts(); } return(PartialView(model)); }
public ActionResult HeaderLinks() { var customer = _services.WorkContext.CurrentCustomer; var unreadMessageCount = GetUnreadPrivateMessages(); var unreadMessage = string.Empty; var alertMessage = string.Empty; if (unreadMessageCount > 0) { unreadMessage = T("PrivateMessages.TotalUnread", unreadMessageCount); //notifications here var notifiedAboutNewPrivateMessagesAttributeKey = string.Format(SystemCustomerAttributeNames.NotifiedAboutNewPrivateMessages, _services.StoreContext.CurrentStore.Id); if (_forumSettings.ShowAlertForPM && !customer.GetAttribute <bool>(SystemCustomerAttributeNames.NotifiedAboutNewPrivateMessages, _services.StoreContext.CurrentStore.Id)) { _genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.NotifiedAboutNewPrivateMessages, true, _services.StoreContext.CurrentStore.Id); alertMessage = T("PrivateMessages.YouHaveUnreadPM", unreadMessageCount); } } var model = new HeaderLinksModel() { IsAuthenticated = customer.IsRegistered(), CustomerEmailUsername = customer.IsRegistered() ? (_customerSettings.UsernamesEnabled ? customer.Username : customer.Email) : "", IsCustomerImpersonated = _services.WorkContext.OriginalCustomerIfImpersonated != null, DisplayAdminLink = _services.Permissions.Authorize(StandardPermissionProvider.AccessAdminPanel), 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 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)); }
/// <summary> /// Prepare the header links model /// </summary> /// <returns>Header links model</returns> public virtual HeaderLinksModel PrepareHeaderLinksModel() { var user = _workContext.CurrentUser; var unreadMessageCount = GetUnreadPrivateMessages(); var unreadMessage = string.Empty; var alertMessage = string.Empty; if (unreadMessageCount > 0) { unreadMessage = string.Format(_localizationService.GetResource("PrivateMessages.TotalUnread"), unreadMessageCount); } var model = new HeaderLinksModel { IsAuthenticated = user.IsRegistered(), UserName = user.IsRegistered() ? _userService.FormatUserName(user) : "", AllowPrivateMessages = user.IsRegistered(), UnreadPrivateMessages = unreadMessage, AlertMessage = alertMessage, }; return(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 FacebookLogin() { var fbModel = new HeaderLinksModel(); fbModel.hdnUserID = "0"; fbModel.hdnOpenFBModal = "0"; fbModel.hdnFBConnectedNeed = "0"; fbModel.hdnIsClearCookie = "0"; fbModel.hdnFbMergeRu = "0"; return PartialView(fbModel); }