public void Clear() { ListHistory.Clear(); HistoryItem h = new HistoryItem(); h.Title = "Google"; h.Url = "https:\\www.google.com"; h.Tanggal = DateTime.UtcNow; h.Id = Utils.GenerateNewUCID(); ListHistory.Add(h); Save(); Load(); }
public void Add(string title, string url) { foreach (HistoryItem item in ListHistory) { if (item.Url == url && item.Title == title) { ListHistory.Remove(item); } } HistoryItem h = new HistoryItem(); h.Title = title; h.Url = url; h.Tanggal = DateTime.UtcNow; h.Id = Utils.GenerateNewUCID(); ListHistory.Add(h); }
public History() { if (!File.Exists(HistoryFile)) { HistoryItem h = new HistoryItem(); h.Title = "Google"; h.Url = "https:\\www.google.com"; h.Tanggal = DateTime.UtcNow; h.Id = Utils.GenerateNewUCID(); ListHistory.Add(h); var history = JsonConvert.SerializeObject(ListHistory); Utils.WriteFileAsync(HistoryFile, history); Load(); } else { Load(); } }