private static string GetApplication(string user) { var currentUser = UserAccountHelper.GetUser(user); var userID = currentUser.UserProfileID; if (currentUser.IsAdmin) { return(Cats.Models.Constant.Application.EARLY_WARNING); } if (currentUser.DefaultHub != null) { return(Cats.Models.Constant.Application.HUB); } if (currentUser.RegionalUser) { return(Cats.Models.Constant.Application.REGIONAL); } switch (currentUser.CaseTeam) { case 1: //EarlyWarning return(Cats.Models.Constant.Application.EARLY_WARNING); break; case 2: //PSNP return(Cats.Models.Constant.Application.PSNP); break; case 3: //Logistics return(Cats.Models.Constant.Application.LOGISTICS); break; case 4: //Procurement return(Cats.Models.Constant.Application.PROCUREMENT); break; case 5: //Finance return(Cats.Models.Constant.Application.FINANCE); break; default: return(""); } }
//public static int GetUnreadNotifications() //{ // try // { // var user = HttpContext.Current.User.Identity.Name; // var app = GetApplication(user); // var notificationService = (INotificationService)DependencyResolver.Current.GetService(typeof(INotificationService)); // var totallUnread = notificationService.GetAllNotification().Where(n => n.IsRead == false && app.Contains(n.Application)).OrderByDescending(n => n.NotificationId).ToList(); // return totallUnread.Count(); // } // catch (Exception) // { // return 0; // } //} public static HtmlString GetActiveNotifications(this HtmlHelper helper, bool isOldTheme = true) { try { var user = HttpContext.Current.User.Identity.Name; var notificationService = (INotificationService)DependencyResolver.Current.GetService(typeof(INotificationService)); List <Cats.Models.Notification> totallUnread = null; var currentUser = UserAccountHelper.GetUser(user); var app = GetApplication(user); if (app == Models.Constant.Application.HUB) { totallUnread = notificationService.GetAllNotification().Where(n => n.IsRead == false && n.Id == currentUser.DefaultHub && app.Contains(n.Application)).OrderByDescending(n => n.NotificationId).ToList(); } else if (app == Models.Constant.Application.REGIONAL) { totallUnread = notificationService.GetAllNotification().Where(n => n.IsRead == false && n.Id == currentUser.RegionID && app.Contains(n.Application)).OrderByDescending(n => n.NotificationId).ToList(); } else { totallUnread = notificationService.GetAllNotification().Where(n => n.IsRead == false && app.Contains(n.Application)).OrderByDescending(n => n.NotificationId).ToList(); } var str = "<ul class='dropdown-menu-list scroller'>"; int max = 0; if (totallUnread.Count < 1) { return(MvcHtmlString.Create("")); } max = totallUnread.Count > 5 ? 5 : totallUnread.Count; for (int i = 0; i < max; i++) { str = str + "<li>"; // str = str + "<a href=" + totallUnread[i].Url + ">"; str = str + "<a style='padding: 10px 5px' href=" + GetRelativeURL(totallUnread[i].Url) + ">"; str = str + totallUnread[i].Text; str = str + "</li>"; str = str + "</a>"; } str = str + "</ul>"; if (totallUnread.Count > 5 && isOldTheme) { var webAppDir = (HttpContext.Current.Request.ApplicationPath == "/") ? "" : HttpContext.Current.Request.ApplicationPath; str += "<a href='" + webAppDir + "/Home/GetUnreadNotificationDetail'> View More </a>"; } return(MvcHtmlString.Create(str)); } catch (Exception) { return(MvcHtmlString.Create("")); } }