Esempio n. 1
0
 public void ClearHistory()
 {
     historyWords.Clear();
     using (BiliMusicContext db = new BiliMusicContext())
     {
         db.SearchHistorys.RemoveRange(db.SearchHistorys);
         db.SaveChangesAsync();
     }
 }
Esempio n. 2
0
 private void SaveHistory(string keyword)
 {
     using (BiliMusicContext db = new BiliMusicContext())
     {
         var search = db.SearchHistorys.FirstOrDefault(x => x.content.Equals(keyword));
         if (search != null)
         {
             search.datetime = DateTime.Now;
         }
         else
         {
             db.SearchHistorys.Add(new SearchHistory()
             {
                 content  = keyword,
                 datetime = DateTime.Now
             });
         }
         db.SaveChangesAsync();
     }
 }