Esempio n. 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();
            }
        }
Esempio n. 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();
        }
Esempio n. 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();
            }
        }
Esempio n. 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();
 }