private void ShowLesson() { ShowModifyLessonSubView = true; using (var db = Database.Instance.GetConnection()) { var lessonsInDatabase = db.Table <Lesson>().Where(l => l.UserId == CurrentUser.Id && l.Name == CurrentLesson.Name); if (lessonsInDatabase.Count() != 1) { CurrentLessonWords.Clear(); Lessons.Remove(CurrentLesson); CurrentLesson = null; return; } CurrentLesson = lessonsInDatabase.First(); CurrentLessonWords = new ObservableCollection <Word>(); CurrentLessonWords.CollectionChanged += CurrentLessonWords_CollectionChanged; foreach (var word in db.Table <Word>().Where(w => w.LessonId == CurrentLesson.Id)) { CurrentLessonWords.Add(word); } CurrentEditingWord = new Word(); OnPropertyChanged("CurrentEditingWord"); OnPropertyChanged("CurrentLessonWords"); OnPropertyChanged("CurrentLesson"); } }
public bool LessonRemove(string name) { if (Lessons.Contains(name)) { Lessons.Remove(name); return(true); } else { return(false); } }
private void DeleteSelectedLesson(object p) { Lesson lessonToRemove = Lessons.Where(l => l.Name.Equals(p as string)).First(); Lessons.Remove(lessonToRemove); using (var db = Database.Instance.GetConnection()) { foreach (Word word in CurrentLessonWords) { RemoveWordIfExists(db, word); } RemoveLessonIfExists(db, lessonToRemove); } }
public void RemoveLesson(Lesson lesson) { Lessons.Remove(lesson); SaveLessons(); }