Ejemplo n.º 1
0
 public Product Get(Expression <Func <Product, bool> > filter)
 {
     using (CarRentalDataBaseContext context = new CarRentalDataBaseContext())
     {
         return(context.Set <Product>().SingleOrDefault(filter));
     }
 }
Ejemplo n.º 2
0
 public List <Product> GetAll(Expression <Func <Product, bool> > filter = null)
 {
     using (CarRentalDataBaseContext context = new CarRentalDataBaseContext())
     {
         return(filter == null?context.Set <Product>().ToList()
                    : context.Set <Product>().Where(filter).ToList());
     }
 }
Ejemplo n.º 3
0
 public void Update(Product entity)
 {
     using (CarRentalDataBaseContext context = new CarRentalDataBaseContext())
     {
         var updatedEntity = context.Entry(entity);
         updatedEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 public void Delete(Product entity)
 {
     using (CarRentalDataBaseContext context = new CarRentalDataBaseContext())
     {
         var deletedEntity = context.Entry(entity);
         deletedEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Ejemplo n.º 5
0
 public void Add(Product entity)
 {
     using (CarRentalDataBaseContext context = new CarRentalDataBaseContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }