Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }