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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }