public List <Color> GetAll(Expression <Func <Color, bool> > filter = null) { using (RentalCarDbContext context = new RentalCarDbContext()) { return(filter == null?context.Set <Color>().ToList() : context.Set <Color>().Where(filter).ToList()); } }
public Color GetById(Expression <Func <Color, bool> > filter) { using (RentalCarDbContext context = new RentalCarDbContext()) { return(context.Set <Color>().SingleOrDefault(filter)); } }
public Brand Get(Expression <Func <Brand, bool> > filter) { using (RentalCarDbContext context = new RentalCarDbContext()) { return(context.Set <Brand>().SingleOrDefault(filter)); } }
public void Update(Color entity) { using (RentalCarDbContext context = new RentalCarDbContext()) { var updatedEntity = context.Entry(entity); updatedEntity.State = EntityState.Modified; context.SaveChanges(); } }
public void Delete(Color entity) { using (RentalCarDbContext context = new RentalCarDbContext()) { var deletedEntity = context.Entry(entity); deletedEntity.State = EntityState.Deleted; context.SaveChanges(); } }
public void Add(Brand entity) { using (RentalCarDbContext context = new RentalCarDbContext()) { var addedEntity = context.Entry(entity); addedEntity.State = EntityState.Added; context.SaveChanges(); } }