/// <summary>
        /// Fetch all the records of type T from the database.
        /// </summary>
        /// <remarks>
        /// Could be costly with a large amount of records.
        /// </remarks>
        public List <T> FetchAll()
        {
            _semaphore.Wait();

            try
            {
                return(_context.Set <T>().ToList());
            }
            finally
            {
                _semaphore.Release();
            }
        }
Example #2
0
        public async Task UpdateEffectAsync(Effect effect)
        {
            // If it doesn't exist in the DB, abort
            if (await _context.Effects.CountAsync(c => c.Id.Equals(effect.Id)) <= 0)
            {
                return;
            }

            var dto = await _context.Effects.FirstOrDefaultAsync(x => x.Id.Equals(effect.Id));

            _mapper.Map <Effect, EffectDto>(effect, dto);
            dto.EffectMappings = await _context.Set <EffectMapping>().Where(x => x.EffectId.Equals(effect.Id)).ToListAsync();

            _context.Update(dto);

            await _context.SaveChangesAsync();
        }
Example #3
0
 /// <summary>
 /// Fetch all the records of type T from the database.
 /// </summary>
 /// <remarks>
 /// Could be costly with a large amount of records.
 /// </remarks>
 public List <T> FetchAll()
 {
     return(_context.Set <T>().ToList());
 }