Example #1
0
 public static Publisher AddPublisher(Publisher publisher)
 {
   if (publisher == null) return null;
   using (var db = new BookshelfDbContext())
   {
     db.Publishers.Add(publisher);
     db.SaveChanges();
     var id = db.Publishers.Max(x => x.Id);
     return db.Publishers.Where(x => x.Id == id).FirstOrDefault();
   }
 }
Example #2
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();
 }