public virtual IEnumerable <TEntity> FindAll(bool isTracked = true) { IQueryable <TEntity> set = context.Set <TEntity>(); if (!isTracked) { set.AsNoTracking(); } return(set.ToList()); }
public async Task <List <T> > GetAll(Expression <Func <T, bool> > filter = null) { using (HotelDbContext context = new HotelDbContext()) { return(filter == null ? await context.Set <T>().ToListAsync() : await context.Set <T>().Where(filter).ToListAsync()); } }
public async Task <T> Get(Expression <Func <T, bool> > filter) { using (HotelDbContext context = new HotelDbContext()) { return(await context.Set <T>().FirstOrDefaultAsync(filter)); } }
public async Task Delete(TId entity) { using (HotelDbContext context = new HotelDbContext()) { var deleteEntity = context.Find <T>(entity); context.Set <T>().Remove(deleteEntity); await context.SaveChangesAsync(); } }
public async Task <T> Update(T entity) { using (HotelDbContext context = new HotelDbContext()) { context.Set <T>().Update(entity); await context.SaveChangesAsync(); return(entity); } }
public void Update(RoomType item) { var ids = item.Conveniences.Select(i => i.Id).ToList(); item.Conveniences = _context.Conveniences .Where(t => ids.Contains(t.Id)) .ToList(); _context.Set <RoomType>().AddOrUpdate(item); _context.SaveChanges(); }
public void Update(Convenience item) { var convenience = _context.Conveniences.Find(item.Id); if (convenience == null) { throw new ArgumentException("Convenience with current Id not found"); } _context.Set <Convenience>().AddOrUpdate(item); _context.SaveChanges(); }
public void Update(Room item) { Room room = _context.Rooms.Find(item.Id); if (room == null) { throw new ArgumentException("Room with current Id not found"); } _context.Set <Room>().AddOrUpdate(item); _context.SaveChanges(); }
public async Task <List <T> > GetAllAsync() { return(await _context.Set <T>().ToListAsync()); }
public void Create(TEntity entity) { _context.Set <TEntity>().AddAsync(entity); }
public GenericRepository(HotelDbContext hotelDbContext) { _hotelDbContext = hotelDbContext; _db = _hotelDbContext.Set <T>(); }
public void Update(Reservation item) { item.RoomType = _context.RoomTypes.Find(item.RoomType.Id); _context.Set <Reservation>().AddOrUpdate(item); _context.SaveChanges(); }
public virtual async Task <IEnumerable <T> > ListAllAsync() { return(await _dbContext.Set <T>().ToListAsync()); }
public async Task <IEnumerable <TEntity> > GetAllAsync() { return(await _context.Set <TEntity>().ToListAsync()); }