Exemplo n.º 1
0
 public Film SelectByTitle(string title)
 {
     using (FilmStoreContext context = new FilmStoreContext())
     {
         return(context.Films.FirstOrDefault(x => x.Title == title));
     }
 }
Exemplo n.º 2
0
 public Film SelectById(long id)
 {
     using (FilmStoreContext context = new FilmStoreContext())
     {
         return(context.Films.FirstOrDefault(x => x.Id == id));
     }
 }
Exemplo n.º 3
0
 public ICollection <Film> SelectAll()
 {
     using (FilmStoreContext context = new FilmStoreContext())
     {
         return(context.Films.ToList());
     }
 }
Exemplo n.º 4
0
 public ICollection <Film> SearchByTitle(string title)
 {
     using (FilmStoreContext context = new FilmStoreContext())
     {
         return(context.Films.Where(x => x.Title.Contains(title)).ToList());
     }
 }
Exemplo n.º 5
0
 public bool Update(Film film)
 {
     using (FilmStoreContext context = new FilmStoreContext())
     {
         context.Entry(film).State = EntityState.Modified;
         int i = context.SaveChanges();
         return(i == 1 ? true : false);
     }
 }
Exemplo n.º 6
0
 public long Insert(Film film)
 {
     using (FilmStoreContext context = new FilmStoreContext())
     {
         context.Entry(film).State = EntityState.Added;
         context.SaveChanges();
         return(film.Id);
     }
 }