Exemple #1
0
 static void AddNewRecord(Entry entry)
 {
     using (var repo = new EntryRepo())
     {
         repo.Add(entry);
     }
 }
Exemple #2
0
 static void DeleteRecord(int entryId)
 {
     using (var repo = new EntryRepo())
     {
         var entryToDelete = repo.GetOne(entryId);
         if (entryToDelete != null)
         {
             repo.Delete(entryToDelete);
         }
     }
 }
Exemple #3
0
 static void PrintAllEntries()
 {
     using (var repo = new EntryRepo())
     {
         foreach (Entry e in repo.GetAll())
         {
             Console.WriteLine(e.ToString());
         }
         Console.WriteLine();
     }
 }
Exemple #4
0
 static void UpdateRecord(int entryId)
 {
     using (var repo = new EntryRepo())
     {
         var entryToUpdate = repo.GetOne(entryId);
         if (entryToUpdate != null)
         {
             entryToUpdate.Subject = "New";
             repo.Save(entryToUpdate);
         }
     }
 }
Exemple #5
0
 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();
     }
 }
Exemple #6
0
 public void SaveEntry()
 {
     try
     {
         using (var repo = new EntryRepo())
         {
             repo.Add(this.NewEntry);
         }
     }
     catch (Exception)
     {
         //  TO DO: determine how to handle this
         return;
     }
 }
Exemple #7
0
        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;
        }