Beispiel #1
0
        public static BookmarkedSessionDAO MapToBookmarkedSessionDAO(BookmarkedSession bookmarkedSessionToMap)
        {
            BookmarkedSessionDAO bookmarkedSessionDAO = new BookmarkedSessionDAO();

            bookmarkedSessionDAO.Id            = bookmarkedSessionToMap.Id;
            bookmarkedSessionDAO.StudentUserId = bookmarkedSessionToMap.StudentUserId;
            bookmarkedSessionDAO.SessionId     = bookmarkedSessionToMap.SessionId;

            return(bookmarkedSessionDAO);
        }
Beispiel #2
0
        public static BookmarkedSession MapToBookmarkedSession(BookmarkedSessionDAO bookmarkedSessionDAOToMap)
        {
            BookmarkedSession bookmarkedSession = new BookmarkedSession();

            bookmarkedSession.Id            = bookmarkedSessionDAOToMap.Id;
            bookmarkedSession.StudentUserId = bookmarkedSessionDAOToMap.StudentUserId;
            bookmarkedSession.SessionId     = bookmarkedSessionDAOToMap.SessionId;

            return(bookmarkedSession);
        }
        public bool RemoveCourseBookmark(BookmarkedSession bookmarkToRemove)
        {
            var matchingBookmarks = db.BookmarkedSessions.Where(bm => bm.Id.Equals(bookmarkToRemove.Id));

            if (matchingBookmarks.Count() > 0)
            {
                db.BookmarkedSessions.Remove(matchingBookmarks.First());
                return(db.SaveChanges() > 0);
            }

            else
            {
                Debug.WriteLine("Bookmark does not contain valid information.");
                return(false);
            }
        }
        public bool AddCourseBookmark(BookmarkedSession bookmarkToAdd)
        {
            List <BookmarkedSession> allBookmarks = db.BookmarkedSessions.ToList();

            var matchingBookmarks1 = allBookmarks.Where(bm => bm.StudentUserId.Equals(bookmarkToAdd.StudentUserId));
            var matchingBookmarks2 = matchingBookmarks1.Where(bm => bm.SessionId.Equals(bookmarkToAdd.SessionId));

            if (matchingBookmarks2.Count() == 0)
            {
                db.BookmarkedSessions.Add(bookmarkToAdd);
                return(db.SaveChanges() > 0);
            }

            else
            {
                Debug.WriteLine("Bookmark already exists.");
                return(false);
            }
        }