Beispiel #1
0
        private async Task <Sport> CreateSportAsync(string name)
        {
            var id = await _sqlConnection.InsertAsync(SportsTable, ColumnValuePair.CreateName(name));

            return(new Sport()
            {
                Id = id,
                Name = name
            });
        }
Beispiel #2
0
        private async Task <Bookkeeper> CreateBookerAsync(string name)
        {
            var id = await _sqlConnection.InsertAsync(BookersTable, ColumnValuePair.CreateName(name));

            return(new Bookkeeper()
            {
                Id = id,
                Name = name
            });
        }
Beispiel #3
0
        private async Task <Country> CreateCountryAsync(string name)
        {
            var id = await _sqlConnection.InsertAsync(CountriesTable, ColumnValuePair.CreateName(name));

            return(new Country()
            {
                Id = id,
                Name = name
            });
        }
Beispiel #4
0
        private async Task <Team> CreateTeamAsync(string name, Sport sport)
        {
            var id = await _sqlConnection.InsertAsync(TeamsTable,
                                                      ColumnValuePair.CreateName(name),
                                                      ColumnValuePair.Create(new ForegnKeyTableColumn(TeamsTable, SportsTable, "Id").ColumnName, sport.Id));

            return(new Team()
            {
                Id = id,
                Name = name,
                Sport = sport
            });
        }
Beispiel #5
0
        public async Task <Sport> GetSportAsync(string name)
        {
            var dbId = await _sqlConnection.GetIdAsync(SportsTable, ColumnValuePair.CreateName(name));

            if (dbId > 0)
            {
                return(new Sport
                {
                    Id = dbId,
                    Name = name
                });
            }

            return(null);
        }
Beispiel #6
0
        private async Task <Bookkeeper> GetBookerAsync(string name)
        {
            var dbId = await _sqlConnection.GetIdAsync(BookersTable, ColumnValuePair.CreateName(name));

            if (dbId > 0)
            {
                return(new Bookkeeper
                {
                    Id = dbId,
                    Name = name
                });
            }

            return(null);
        }
Beispiel #7
0
        public async Task <Country> GetCountryAsync(string name)
        {
            var dbId = await _sqlConnection.GetIdAsync(CountriesTable, ColumnValuePair.CreateName(name));

            if (dbId > 0)
            {
                return(new Country
                {
                    Id = dbId,
                    Name = name
                });
            }

            return(null);
        }
Beispiel #8
0
        private async Task <League> CreateLeagueAsync(string name, bool isFirst, Sport sport, Country country)
        {
            var id = await _sqlConnection.InsertAsync(LeaguesTable,
                                                      ColumnValuePair.CreateName(name),
                                                      ColumnValuePair.Create(new ForegnKeyTableColumn(LeaguesTable, SportsTable, "Id").ColumnName, sport.Id),
                                                      ColumnValuePair.Create(new ForegnKeyTableColumn(LeaguesTable, CountriesTable, "Id").ColumnName, country.Id),
                                                      ColumnValuePair.Create(nameof(League.IsFirst), isFirst));

            return(new League()
            {
                Id = id,
                Name = name,
                Sport = sport,
                Country = country,
                IsFirst = isFirst
            });
        }
Beispiel #9
0
        public async Task <Team> GetTeamAsync(string name, Sport sport)
        {
            var dbId = await _sqlConnection.GetIdAsync(TeamsTable,
                                                       ColumnValuePair.CreateName(name),
                                                       ColumnValuePair.Create(new ForegnKeyTableColumn(TeamsTable, SportsTable, "Id").ColumnName, sport.Id));

            if (dbId > 0)
            {
                return(new Team
                {
                    Id = dbId,
                    Name = name,
                    Sport = sport
                });
            }

            return(null);
        }
Beispiel #10
0
        public async Task <League> GetLeagueAsync(string name, Sport sport, Country country)
        {
            var dbId = await _sqlConnection.GetIdAsync(LeaguesTable,
                                                       ColumnValuePair.CreateName(name),
                                                       ColumnValuePair.Create(new ForegnKeyTableColumn(LeaguesTable, SportsTable, "Id").ColumnName, sport.Id),
                                                       ColumnValuePair.Create(new ForegnKeyTableColumn(LeaguesTable, CountriesTable, "Id").ColumnName, country.Id));

            if (dbId > 0)
            {
                return(new League
                {
                    Id = dbId,
                    Name = name,
                    Sport = sport,
                    Country = country
                });
            }

            return(null);
        }