public static void AddorUpdateHistoryItem(string title, string url) { var realm = Realm.GetInstance(); var item = realm.All <History>().FirstOrDefault(x => x.Title == title && x.Url == url); using (var trans = realm.BeginWrite()) { if (item == null) { var auth = FaviconHelper.GetAuthority(url); var fav = FaviconHelper.GetFavicon(auth); item = new History { Id = GetHistoryData().Count() + 1, Title = title, Favicon = fav, Visted = "Visited: " + DateTime.Now.ToString("D") }; realm.Add(item); } else { realm.Add(item, true); } trans.Commit(); } }
public static void AddItem(string title, string url) { urlHistory.Add(new History() { Id = urlHistory.Count + 1, Title = title, Url = url, Favicon = FaviconHelper.GetFavicon(FaviconHelper.GetAuthority(url)), VisitDateTime = DateTime.Now }); }
public static void AddBookmark(string title, string url) { var authority = FaviconHelper.GetAuthority(url); var realm = Realm.GetInstance(); using (var trans = realm.BeginWrite()) { var bookmark = new Bookmark { Id = GetBookmarksData().Count(), Title = title, Url = url, Favicon = FaviconHelper.GetFavicon(authority) }; realm.Add(bookmark); trans.Commit(); } }