Exemplo n.º 1
0
        private LeaguesContext CreateContextAndMigrateDb()
        {
            var leaguesContext = LeaguesContextFactory.Create();

            leaguesContext.Database.Migrate();
            return(leaguesContext);
        }
Exemplo n.º 2
0
        public async Task GetLeagueById(int id, TaskCompletionSource <League> receivedTask)
        {
            await using (var context = LeaguesContextFactory.Create())
            {
                try
                {
                    var entity = await context.Leagues
                                 .Include(l => l.LeagueSettings)
                                 .SingleOrDefaultAsync(l => l.Id == id);

                    receivedTask.TrySetResult(entity);
                }
                catch (Exception e)
                {
                    receivedTask.TrySetException(e);
                }
            }
        }
Exemplo n.º 3
0
        public async Task GetLeagueByName(string name, TaskCompletionSource <League> receivedTask)
        {
            await using (var context = LeaguesContextFactory.Create())
            {
                try
                {
                    var entity = await context.Leagues
                                 .SingleOrDefaultAsync(l => l.Name == name);

                    if (entity is null)
                    {
                        receivedTask.TrySetCanceled();
                    }
                    receivedTask.TrySetResult(entity);
                }
                catch (Exception e)
                {
                    receivedTask.TrySetException(e);
                }
            }
        }