Пример #1
0
 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();
 }
Пример #2
0
 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();
 }
Пример #3
0
 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();
 }
Пример #4
0
 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;
 }
Пример #5
0
 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;
 }
Пример #6
0
 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;
 }