public async Task Handle(DeleteNewRecentUserByUsernameCommand command)
        {
            var recentUser = await _context.RecentUsers
                             .SingleOrDefaultAsync(x => x.Username == command.Username);

            if (recentUser == null)
            {
                throw new RecentUserNotFoundException(command.Username);
            }

            _context.Remove(recentUser);
            await _context.SaveChangesAsync();
        }
Example #2
0
        public async Task DeleteRecentUsers()
        {
            await using var db = new TestApiDbContext(_dbContextOptions);

            var recentUsers = await db.RecentUsers
                              .Where(x => x.Username == EmailData.RECENT_USER_USERNAME)
                              .AsNoTracking()
                              .ToListAsync();

            foreach (var user in recentUsers)
            {
                db.Remove(user);
                await db.SaveChangesAsync();
            }
        }
Example #3
0
        public async Task DeleteUsers()
        {
            await using var db = new TestApiDbContext(_dbContextOptions);

            var users = await db.Users
                        .Where(x => x.Application == Application.TestApi.MapToContractEnum())
                        .AsNoTracking()
                        .ToListAsync();

            foreach (var user in users)
            {
                db.Remove(user);
                await db.SaveChangesAsync();
            }
        }