private void ClickNewVerse(object o) { EditVerseWindow verseDialog = new EditVerseWindow(); verseDialog.ShowDialog(); if (verseDialog.DialogResult == true) { var context = (VerseViewModel)verseDialog.DataContext; VerseDTO verse = new VerseDTO() { BeliefId = SelectedBelief.Id, Book = context.BookList.IndexOf(context.SelectedBook), Chapter = context.SelectedChapter, VerseStart = context.SelectedVerseStart, VerseEnd = context.SelectedVerseEnd }; long newId = BibleBeliefsRepository.CreateVerse(verse); Verses = BibleBeliefsRepository.GetVerses(SelectedBelief.Id); var v = Verses.Single(s => s.Id == newId); if (v != null) { SelectedVerse = v; } } }
private void ClickEditVerse(object o) { EditVerseWindow verseDialog = new EditVerseWindow(); var context = (VerseViewModel)verseDialog.DataContext; context.SelectedBook = context.BookList[(int)(SelectedVerse.Book)]; context.SelectedChapter = (int)SelectedVerse.Chapter; context.SelectedVerseStart = (int)SelectedVerse.VerseStart; context.SelectedVerseEnd = (int)SelectedVerse.VerseEnd; verseDialog.ShowDialog(); if (verseDialog.DialogResult == true) { SelectedVerse.Book = context.BookList.IndexOf(context.SelectedBook); SelectedVerse.Chapter = context.SelectedChapter; SelectedVerse.VerseStart = context.SelectedVerseStart; SelectedVerse.VerseEnd = context.SelectedVerseEnd; if (SelectedVerse.VerseEnd < SelectedVerse.VerseStart) { SelectedVerse.VerseEnd = SelectedVerse.VerseStart; //Verses must be in order. } BibleBeliefsRepository.UpdateVerse(_SelectedVerse); } Verses = BibleBeliefsRepository.GetVerses(_SelectedVerse.BeliefId); }