static void AddNewRecord(Entry entry) { using (var repo = new EntryRepo()) { repo.Add(entry); } }
static void DeleteRecord(int entryId) { using (var repo = new EntryRepo()) { var entryToDelete = repo.GetOne(entryId); if (entryToDelete != null) { repo.Delete(entryToDelete); } } }
static void PrintAllEntries() { using (var repo = new EntryRepo()) { foreach (Entry e in repo.GetAll()) { Console.WriteLine(e.ToString()); } Console.WriteLine(); } }
static void UpdateRecord(int entryId) { using (var repo = new EntryRepo()) { var entryToUpdate = repo.GetOne(entryId); if (entryToUpdate != null) { entryToUpdate.Subject = "New"; repo.Save(entryToUpdate); } } }
static void PrintSubjects() { using (var repo = new EntryRepo()) { IList <Entry> entries = repo.GetAll(); HashSet <string> subjects = new HashSet <string>(from e in entries select e.Subject); foreach (string s in subjects) { Console.WriteLine(s); } Console.WriteLine(); } }
public void SaveEntry() { try { using (var repo = new EntryRepo()) { repo.Add(this.NewEntry); } } catch (Exception) { // TO DO: determine how to handle this return; } }
public MainWindowViewModel() { try { using (var repo = new EntryRepo()) { _entries = new List <Entry>(repo.GetAll()); } } catch (Exception) { MessageBox.Show("Unable to connect to data source", "Study Application"); Environment.Exit(1); } uniqueSubjects = new ObservableCollection <string>(_entries.Select(e => e.Subject).Distinct().OrderBy(s => s)); newSubject = new NewSubject(uniqueSubjects); DurationTimer = new Timer(state => DurationTimer_Tick(), null, Timeout.Infinite, 1000); DurationTimerRunning = false; }