// public CarBrandRepos() // { // } public void Add(CarBrands carBrand) { using (var context = new CarShopContext()) { context.CarBrands.Add(carBrand); context.SaveChanges(); } }
public void Update(CarBrands carBrand) { using (var context = new CarShopContext()) { var entity = context.CarBrands.Find(carBrand.Id); context.Entry(entity).CurrentValues.SetValues(carBrand); context.SaveChanges(); } }
public IEnumerable <CarBrands> Find(Expression <Func <CarBrands, bool> > predicate, Expression <Func <CarBrands, object> > includedProperties = null) { using (var context = new CarShopContext()) { return(includedProperties != null ? context.CarBrands.Include(includedProperties).Where(predicate).ToArray() : context.CarBrands.Where(predicate).ToArray()); } }
public void Remove(Guid id) { using (var context = new CarShopContext()) { CarBrands carBrand = this.Find(x => x.Id == id).FirstOrDefault(); //this.Get(Id); using (var db = this.GetContext()) { // db.CarBrands.Remove(carBrand); - // We can't use remove as we retrieved entity in other db context that is already closed // Rather we can attach entry to a current dbContext and mark it as deleted db.Entry(carBrand).State = EntityState.Deleted; db.SaveChanges(); } } }
public ShopRespository(CarShopContext context) : base(context) { }
public UserRepo(CarShopContext context) { db = context; }
public CarRepository(CarShopContext carShopContext) { _carShopContext = carShopContext; }
public UnitOfWork() { db = new CarShopContext(); _repo = new Dictionary <Type, object>(); }
public PurchasesController(CarShopContext context) { _context = context; }
public CarRepository(CarShopContext context) : base(context) { }
public ToolsController(CarShopContext context) { _context = context; }
public RepairRequestsController(CarShopContext context) { _context = context; }
public PartsController(CarShopContext context) { _context = context; }
public Repository(CarShopContext con) { db = con; dbSet = db.Set <T>(); }