예제 #1
0
 public Book GetBook(int id)
 {
     try {
         using (var context = new MediaEntities())
         {
             return(context.Books.Find(id));
         }
     }
     catch (Exception e)
     {
         throw new Exception("Couldnt find media", e);
     }
 }
예제 #2
0
 public List <Movy> GetAllMovies()
 {
     try
     {
         using (var context = new MediaEntities())
         {
             return(context.Movies.ToList());
         }
     }
     catch (Exception e)
     {
         throw new Exception("Couldnt get to database", e);
     }
 }
예제 #3
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);
     }
 }
예제 #4
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);
     }
 }
예제 #5
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);
     }
 }
예제 #6
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);
     }
 }
예제 #7
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);
     }
 }
예제 #8
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);
     }
 }