public void Delete <E>(E id)
 {
     using (var db = new CinemaBookingDBEntities())
     {
         var entity = db.Set <T>().Find(id);
         if (entity != null)
         {
             db.Set <T>().Remove(entity);
         }
         db.SaveChanges();
     }
 }
 public List <T> GetAll()
 {
     using (var db = new CinemaBookingDBEntities())
     {
         return(db.Set <T>().ToList());
     }
 }
 public List <T> FindByTop(int index)
 {
     using (var db = new CinemaBookingDBEntities())
     {
         return(db.Set <T>().Take <T>(index).ToList());
     }
 }
 public List <T> FindBy(System.Linq.Expressions.Expression <Func <T, bool> > predicate)
 {
     using (var db = new CinemaBookingDBEntities())
     {
         return(db.Set <T>().Where(predicate).ToList());
     }
 }
 public T FindByID <E>(E id)
 {
     using (var db = new CinemaBookingDBEntities())
     {
         return(db.Set <T>().Find(id));
     }
 }
 public void Create(T entity)
 {
     using (var db = new CinemaBookingDBEntities())
     {
         db.Set <T>().Add(entity);
         db.SaveChanges();
     }
 }
Esempio n. 7
0
 public int createCustomer(Customer cus)
 {
     using (var db = new CinemaBookingDBEntities())
     {
         db.Set <Customer>().Add(cus);
         db.SaveChanges();
         return(cus.customerId);
     }
 }
 public int CreateOrder(BookingTicket entity)
 {
     using (var db = new CinemaBookingDBEntities())
     {
         db.Set <BookingTicket>().Add(entity);
         db.SaveChanges();
         return(entity.bookingId);
     }
 }