Example #1
0
 /// <summary>
 /// Finds object with the specified key in the database and returns it
 /// </summary>
 /// <param name="key">Key of the object you wish to find</param>
 /// <returns>Object with the matching key</returns>
 public virtual async Task <T> GetObjectByKeyAsync(int key)
 {
     await using (var context = new DimselabDbContext())
     {
         return(await context.Set <T>().FindAsync(key));
     }
 }
Example #2
0
 /// <summary>
 /// Gets all objects of the type from the database
 /// </summary>
 /// <returns>Returns all objects in the Set of the given type as List</returns>
 public virtual async Task <IEnumerable <T> > GetObjectsAsync()
 {
     await using (var context = new DimselabDbContext())
     {
         return(await context.Set <T>().AsNoTracking().ToListAsync());
     }
 }
Example #3
0
 /// <summary>
 /// Updates the given object in the database
 /// </summary>
 /// <param name="obj">The updated object</param>
 /// <returns>async Task</returns>
 public virtual async Task UpdateObjectAsync(T obj)
 {
     await using (var context = new DimselabDbContext())
     {
         context.Set <T>().Update(obj);
         await context.SaveChangesAsync();
     }
 }
Example #4
0
 public async Task <IEnumerable <Item> > GetObjectsAsync()
 {
     return(await dbContext.Set <Item>().AsNoTracking().ToListAsync());
 }
 public async Task <Booking> GetObjectByKeyAsync(int id)
 {
     return(await dbContext.Set <Booking>().FindAsync(id));
 }
            public async Task AddObjectAsync(User obj)
            {
                await dbContext.Set <User>().AddAsync(obj);

                await dbContext.SaveChangesAsync();
            }