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