Esempio n. 1
0
 public void DeleteBook(int id)
 {
     try
     {
         using (var context = new MediaEntities())
         {
             context.Books.Remove(context.Books.Find(id));
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw new Exception("Couldnt find media", e);
     }
 }
Esempio n. 2
0
 public void EditPaper(int id, string name)
 {
     try
     {
         using (var context = new MediaEntities())
         {
             context.Papers.Find(id).Name = name;
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw new Exception("Couldnt add to db", e);
     }
 }
Esempio n. 3
0
 public void AddMovie(Movy movie)
 {
     try
     {
         using (var context = new MediaEntities())
         {
             context.Movies.Add(movie);
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw new Exception("Couldnt add to db", e);
     }
 }
Esempio n. 4
0
 public void AddPaper(Paper paper)
 {
     try
     {
         using (var context = new MediaEntities())
         {
             context.Papers.Add(paper);
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw new Exception("Couldnt add to db", e);
     }
 }
Esempio n. 5
0
 public void AddBook(Book book)
 {
     try
     {
         using (var context = new MediaEntities())
         {
             context.Books.Add(book);
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw new Exception("Couldnt add to db", e);
     }
 }
Esempio n. 6
0
 public static void Edit(this Movy movie, string name)
 {
     try
     {
         using (var context = new MediaEntities())
         {
             movie.Name = name;
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw new Exception("Could not save media", e);
     }
 }