Beispiel #1
0
        /// <summary>
        /// Remove existing bookmark by ID.
        /// </summary>
        /// <param name="id"></param>
        public void RemoveBookmark(int id)
        {
            DataBookmark bookmark = this.Bookmarks.Where(b => b.Id == id).FirstOrDefault();

            if (bookmark != null)
            {
                this.Bookmarks.Remove(bookmark);
                this.SaveChanges();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Add new bookmark.
        /// </summary>
        /// <param name="bookmark"></param>
        public void SaveBookmark(Bookmark bookmark)
        {
            DataBookmark dataBookmark = new DataBookmark()
            {
                Id        = bookmark.id,
                Name      = bookmark.name,
                Username  = bookmark.username,
                Settings  = bookmark.settings,
                Favourite = bookmark.favourite
            };

            this.Bookmarks.Add(dataBookmark);
            this.SaveChanges();
        }
Beispiel #3
0
        /// <summary>
        /// Update existing bookmark by ID.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="bookmark"></param>
        public void UpdateBookmark(Bookmark bookmark)
        {
            var userBookmarks = this.Bookmarks.Where(b => b.Username == bookmark.username);

            foreach (var b in userBookmarks)
            {
                b.Favourite = false;
            }

            DataBookmark dataBookmark = this.Bookmarks.Where(b => b.Id == bookmark.id).FirstOrDefault();

            if (bookmark != null)
            {
                dataBookmark.Favourite = bookmark.favourite;
                dataBookmark.Id        = bookmark.id;
                dataBookmark.Name      = bookmark.name;
                dataBookmark.Settings  = bookmark.settings;
                dataBookmark.Username  = bookmark.username;
                this.SaveChanges();
            }
        }
Beispiel #4
0
 /// <summary>
 /// Add new bookmark.
 /// </summary>
 /// <param name="bookmark"></param>
 public void SaveBookmark(Bookmark bookmark)
 {
     DataBookmark dataBookmark = new DataBookmark() {
         Id = bookmark.id,
         Name = bookmark.name,
         Username = bookmark.username,
         Settings = bookmark.settings,
         Favourite = bookmark.favourite
     };
     this.Bookmarks.Add(dataBookmark);
     this.SaveChanges();
 }