예제 #1
0
        // Extension method to easily get the count of the tickets a dev is working on.
        // used for badges.
        public static int MyWorkingTicketCount(this System.Security.Principal.IPrincipal user)
        {
            using (var db = new BugTrackerEntities())
            {
                int userID    = user.GetID();
                int myTickets = db.Tickets.Count(t => t.AssignedToID == userID);

                return(myTickets);
            }
        }
예제 #2
0
        // returns the number of Notifications not read yet.
        public static string NotifyBadgeCount(this System.Security.Principal.IPrincipal user)
        {
            using (var db = new BugTrackerEntities())
            {
                int    userId = user.GetID();
                string count  = db.Notifications
                                .Count(n => n.ToID == userId && n.BeenRead == false)
                                .ToString();

                // add a "+" if it's greater than 1.s
                string badge = (count != "0") ? "+" + count : count;

                return(badge);
            }
        }