private Publisher AddPublisherCommon()
 {
   var dlg = new AddValueWindow(AddNewPublisherLabelText);
   if (dlg.ShowDialog() == false) return null;
   var value = dlg.GetValue();
   if (value == null || value == string.Empty) return null;
   if (!PublisherList.Where(x => x.Name == value).Any())
   {
     var Publisher = new Publisher();
     Publisher.Name = value;
     using (var db = new BookshelfDbContext())
     {
       db.Publishers.Add(Publisher);
       db.SaveChanges();
     }
     OnPropertyChanged("PublisherList");
   }
   return PublisherList.Where(x => x.Name == value).First();
 }
 private Country AddCountryCommon()
 {
   var dlg = new AddValueWindow(AddNewCountryLabelText);
   if (dlg.ShowDialog() == false) return null;
   var value = dlg.GetValue();
   if (value == null || value == string.Empty) return null;
   if (!CountryList.Where(x => x.Name == value).Any())
   {
     var country = new Country();
     country.Name = value;
     using (var db = new BookshelfDbContext())
     {
       db.Countries.Add(country);
       db.SaveChanges();
     }
     OnPropertyChanged("CountryList");
   }
   return CountryList.Where(x => x.Name == value).First();
 }
 private Language AddLanguageCommon()
 {
   var dlg = new AddValueWindow(AddNewLanguageLabelText);
   if (dlg.ShowDialog() == false) return null;
   var value = dlg.GetValue();
   if (value == null || value == string.Empty) return null;
   if (!LanguageList.Where(x => x.Name == value).Any())
   {
     var language = new Language();
     language.Name = value;
     using (var db = new BookshelfDbContext())
     {
       db.Languages.Add(language);
       db.SaveChanges();
     }
     OnPropertyChanged("LanguageList");
   }
   return LanguageList.Where(x => x.Name == value).First();
 }
 private void AddType(object sender)
 {
   var dlg = new AddValueWindow(AddNewTypeLabelText);
   if (dlg.ShowDialog() == false) return;
   var value = dlg.GetValue();
   if (value == null || value == string.Empty) return;
   if (!TypeList.Where(x => x.Name == value).Any())
   {
     var type = new DB.Type();
     type.Name = value;
     using (var db = new BookshelfDbContext())
     {
       db.Types.Add(type);
       db.SaveChanges();
     }
     OnPropertyChanged("TypeList");
   }
   var tType = TypeList.Where(x => x.Name == value).First();
   if (tType != null)
     TypeID = tType.Id;
 }
 private void AddSeries(object sedner)
 {
   var dlg = new AddValueWindow(AddNewSeriesLabelText);
   if (dlg.ShowDialog() == false) return;
   var value = dlg.GetValue();
   if (value == null || value == string.Empty) return;
   if (!SeriesList.Where(x => x.Name == value).Any())
   {
     var series = new Series();
     series.Name = value;
     using (var db = new BookshelfDbContext())
     {
       db.Series.Add(series);
       db.SaveChanges();
     }
     OnPropertyChanged("SeriesList");
   }
   var tSeries = SeriesList.Where(x => x.Name == value).First();
   if (tSeries != null)
     SeriesID = tSeries.Id;
 }
 private void AddAuthor(object sender)
 {
   var dlg = new AddValueWindow(AddNewAuthorLabelText);
   if (dlg.ShowDialog() == false) return;
   var value = dlg.GetValue();
   if (value == null || value == string.Empty) return;
   if (!AuthorList.Where(x => x.Name == value).Any())
   {
     var author = new Author();
     author.Name = value;
     using (var db = new BookshelfDbContext())
     {
       db.Authors.Add(author);
       db.SaveChanges();
     }
     OnPropertyChanged("AuthorList");
   }
   var tAuthor = AuthorList.Where(x => x.Name == value).First();
   if (tAuthor != null)
     AuthorID = tAuthor.Id;
 }