コード例 #1
0
        /// <summary>
        /// Gets the hidden notification information from the view,
        /// and alters the hidden notification table to match
        /// </summary>
        /// <param name="HideNotifs">List of hidden notifications</param>
        /// <param name="cl">the class to check</param>
        /// <returns>Class Index page for students</returns>
        public ActionResult SaveHideNotifs([Bind(Include = "Hidden, NotifID, ClassID")] List <HideNotifList> HideNotifs, [Bind(Include = "ClassID")] Class cl)
        {
            if (HideNotifs == null || HideNotifs.Count == 0)
            {
                return(RedirectToAction("Index", "Students", new { classId = cl.ClassID }));
            }
            if (test(HideNotifs.First().ClassID) != null)
            {
                return(test(HideNotifs.First().ClassID));
            }
            ClassNotification TempNotif = null;
            StudentVM         Student   = getSVM(HideNotifs.First().ClassID);

            foreach (HideNotifList TempHidden in HideNotifs)
            {
                TempNotif = db.ClassNotifications.Where(c => c.ClassNotificationID == TempHidden.NotifID).FirstOrDefault();
                if (TempHidden.Hidden)
                {
                    CheckHidden(TempNotif);
                }
                else
                {
                    CheckNotHidden(TempNotif);
                }
            }
            return(RedirectToAction("Index", "Students", new { classId = HideNotifs.First().ClassID }));
        }
コード例 #2
0
        /// <summary>
        /// notification is marked as not hidden, checks to make sure notification
        /// isn't in hidden notification table, removes if necessary
        /// </summary>
        /// <param name="Notif">Notification to check</param>
        /// <returns>true if successful</returns>
        public Boolean CheckNotHidden(ClassNotification Notif)
        {
            var  idid = User.Identity.GetUserId();
            User user = db.Users.Where(a => a.IdentityID == idid).FirstOrDefault();

            Boolean rtn    = true;
            Boolean hidden = db.HiddenNotifications.Where(h => h.ClassNotificationID == Notif.ClassNotificationID && h.UsersID == user.UsersID).FirstOrDefault() != null;

            if (hidden)
            {
                HiddenNotification HiddenTemp = db.HiddenNotifications.Where(h => h.ClassNotificationID == Notif.ClassNotificationID && h.UsersID == user.UsersID).FirstOrDefault();
                db.RemoveHiddenNotif(HiddenTemp);
                db.SaveChanges();
            }
            return(rtn);
        }
コード例 #3
0
        /// <summary>
        /// Gets the List of notifications for the class, hiding any
        /// that are in the Hide Notifications Table
        /// </summary>
        /// <param name="UsersID">ID of the User</param>
        /// <param name="classID">ID of Class</param>
        /// <returns>A List of Class Notifications</returns>
        public List <ClassNotification> GetNotifs(int UsersID, int classID)
        {
            List <HiddenNotification> HiddenNotifs = db.HiddenNotifications.Where(n => n.UsersID == UsersID && n.ClassID == classID).ToList();

            if (HiddenNotifs == null)
            {
                return(db.ClassNotifications.Where(i => i.ClassID == classID).OrderBy(i => i.TimePosted).ToList());
            }
            else
            {
                List <ClassNotification> NotifList = db.ClassNotifications.Where(i => i.ClassID == classID).OrderBy(i => i.TimePosted).ToList();
                ClassNotification        Temp      = null;
                foreach (HiddenNotification h in HiddenNotifs)
                {
                    Temp = NotifList.FirstOrDefault(c => c.ClassNotificationID == h.ClassNotificationID);
                    if (Temp != null)
                    {
                        NotifList.Remove(Temp);
                        Temp = null;
                    }
                }
                return(NotifList);
            }
        }
コード例 #4
0
        public void AddNotif(ClassNotification notif)
        {
            List <ClassNotification> temp = ClassNotifications.ToList();

            temp.Add(notif);
        }
コード例 #5
0
//--------------------Add and Remove methods for unit tests------------------
        //Convert IEnumerable into a list to add or remove from it
        //Haven't tested if the changes save or if we need to save them manually
        public void RemoveNotif(ClassNotification notif)
        {
            List <ClassNotification> temp = ClassNotifications.ToList();

            temp.Remove(notif);
        }
コード例 #6
0
 public void AddNotif(ClassNotification notif)
 {
     db.ClassNotifications.Add(notif);
 }
コード例 #7
0
 public void RemoveNotif(ClassNotification notif)
 {
     db.ClassNotifications.Remove(notif);
 }