示例#1
0
        /// <summary>
        ///     Retrieve all the notifications with numbers higher than the current users notification number
        /// </summary>
        /// <returns>List of notifications</returns>
        public List <string> RetrieveNotifications(string type)
        {
            List <string> results = new List <string>();

            using (OdinContext context = this.contextFactory.CreateContext())
            {
                int userInt = (from o in context.OdinUserRoles where o.Username == GlobalData.UserName select o.NotificationNumber).FirstOrDefault();
                List <OdinNotifications> odinNotifications = new List <OdinNotifications>();
                if (type == "User")
                {
                    odinNotifications = (from o in context.OdinNotifications where o.NotificationNumber > userInt orderby o.Date select o).ToList();
                }
                else if (type == "All")
                {
                    odinNotifications = (from o in context.OdinNotifications orderby o.Date select o).ToList();
                }
                foreach (OdinNotifications x in odinNotifications)
                {
                    results.Add(DbUtil.DateTrim(x.Date.ToString()) + " : " + x.Notification);
                }
            }
            return(results);
        }