public List <Car> GetAll(Expression <Func <Car, bool> > filter = null) { using (CarRentalContext carRentalContext = new CarRentalContext()) { return(filter == null?carRentalContext.Set <Car>().ToList() : carRentalContext.Set <Car>().Where(filter).ToList()); } }
public void Add(Car car) { using (CarRentalContext carRentalContext = new CarRentalContext()) { var addedContext = carRentalContext.Entry(car); addedContext.State = EntityState.Added; carRentalContext.SaveChanges(); } }
public void Delete(Car car) { using (CarRentalContext carRentalContext = new CarRentalContext()) { var deletedContext = carRentalContext.Entry(car); deletedContext.State = EntityState.Deleted; carRentalContext.SaveChanges(); } }
public Car GET(Expression<Func<Car, bool>> filter) { using (CarRentalContext context = new CarRentalContext()) { return context.Set<Car>().SingleOrDefault(filter); } }
public void Update(Brand entity) { using (CarRentalContext context = new CarRentalContext()) { var updatedBrand = context.Entry(entity); updatedBrand.State = EntityState.Modified; context.SaveChanges(); } }
public void Delete(Colors entity) { using (CarRentalContext context = new CarRentalContext()) { var deletedEntity = context.Entry(entity); deletedEntity.State = EntityState.Deleted; context.SaveChanges(); } }
public IList <Brand> GetAll(Expression <Func <Brand, bool> > filter = null) { using (CarRentalContext context = new CarRentalContext()) { return(filter == null ? context.Set <Brand>().ToList() : context.Set <Brand>().Where(filter).ToList()); } }
public void Delete(Brand entity) { using (CarRentalContext context = new CarRentalContext()) { var deletedBrand = context.Entry(entity); deletedBrand.State = EntityState.Deleted; context.SaveChanges(); } }
public void Add(Car entity) { using (CarRentalContext context = new CarRentalContext()) { var addedEntity = context.Entry(entity); addedEntity.State = EntityState.Added; context.SaveChanges(); } }
public void Update(Customer entity) { using (CarRentalContext context = new CarRentalContext()) { var updatedCustomer = context.Entry(entity); updatedCustomer.State = EntityState.Modified; context.SaveChanges(); } }
public void Delete(Customer entity) { using (CarRentalContext context = new CarRentalContext()) { var deletedCustomer = context.Entry(entity); deletedCustomer.State = EntityState.Deleted; context.SaveChanges(); } }
public void Update(Brand entity) { using (CarRentalContext context = new CarRentalContext()) { var updatedEntity = context.Entry(entity); updatedEntity.State = EntityState.Added;// EnstityState için using kullandık context.SaveChanges(); } }
public void Update(Car entity) { using (CarRentalContext context = new CarRentalContext()) { var UpdatedEntity = context.Entry(entity); UpdatedEntity.State = EntityState.Modified; context.SaveChanges(); } }
public void Update(Car car) { using (CarRentalContext carRentalContext = new CarRentalContext()) { var updatedContext = carRentalContext.Entry(car); updatedContext.State = EntityState.Modified; carRentalContext.SaveChanges(); } }
public IList <Car> GetAll(Expression <Func <Car, bool> > filter = null) { //IDisposible pattern implementation of c# using (CarRentalContext context = new CarRentalContext()) { return(filter == null ? context.Set <Car>().ToList() : context.Set <Car>().Where(filter).ToList()); } }
public void Add(Brand entity) { if (entity.BrandName.Length > 2) { using (CarRentalContext context = new CarRentalContext()) { var addedBrand = context.Entry(entity); addedBrand.State = EntityState.Added; context.SaveChanges(); } } else { throw new Exception("Brand name must be at least 2 character"); } }
public void Add(Car entity) { if (entity.DailyPrice > 0) { using (CarRentalContext context = new CarRentalContext()) { var addedCar = context.Entry(entity); addedCar.State = EntityState.Added; context.SaveChanges(); } } else { throw new Exception("Daily Price must bigger than zero"); } }