Esempio n. 1
0
 public IEnumerable <Race> GetByTournamentId(Guid tournamentId)
 {
     using (var ctx = new FormulaDContext(_options))
     {
         return(ctx.Set <Race>().GetRacesByTournmentId(tournamentId)?.ToList());
     }
 }
Esempio n. 2
0
 public IEnumerable <TournamentStanding> GetTournamentStandingsById(Guid id)
 {
     using (var ctx = new FormulaDContext(_options))
     {
         return(ctx.Set <TournamentStanding>().Where(ts => ts.TournamentId.Equals(id)).ToList());
     }
 }
Esempio n. 3
0
 public IEnumerable <Tournament> FindByPartialName(string partialName)
 {
     using (var ctx = new FormulaDContext(_options))
     {
         return(ctx.Set <Tournament>().ByPartialName(partialName).ToList());
     }
 }
Esempio n. 4
0
 public Race GetById(Guid id)
 {
     using (var ctx = new FormulaDContext(_options))
     {
         return(ctx.Set <Race>().SingleOrDefault(r => r.Id.Equals(id)));
     }
 }
Esempio n. 5
0
 public Racer GetByName(string name)
 {
     using (var ctx = new FormulaDContext(_options))
     {
         return(ctx.Set <Racer>().SingleOrDefault(r => r.Username.Equals(name, StringComparison.OrdinalIgnoreCase)));
     }
 }
Esempio n. 6
0
 public Tournament FindByName(string name)
 {
     using (var ctx = new FormulaDContext(_options))
     {
         return(ctx.Set <Tournament>()
                .SingleOrDefault(t => t.Name.Equals(name)));
     }
 }
Esempio n. 7
0
 public Tournament GetById(Guid id)
 {
     using (var ctx = new FormulaDContext(_options))
     {
         return(ctx.Set <Tournament>()
                .SingleOrDefault(t => t.Id.Equals(id)));
     }
 }
Esempio n. 8
0
 public RaceStanding AddRaceStanding(RaceStanding raceStanding)
 {
     using (var ctx = new FormulaDContext(_options)){
         ctx.Set <RaceStanding>().Add(raceStanding);
         ctx.SaveChanges();
         return(raceStanding);
     }
 }
Esempio n. 9
0
        public Racer CreateRacer(string name)
        {
            using (var ctx = new FormulaDContext(_options))
            {
                var racer = new Racer {
                    Id = Guid.NewGuid(), Username = name
                };
                ctx.Set <Racer>().Add(racer);

                ctx.SaveChanges();
                return(racer);
            }
        }
Esempio n. 10
0
        public Tournament CreateTournament(string name, int raceCount)
        {
            var tournament = new Tournament
            {
                Id        = Guid.NewGuid(),
                Name      = name,
                RaceCount = raceCount,
                StartDate = DateTime.Now
            };

            using (var ctx = new FormulaDContext(_options))
            {
                ctx.Set <Tournament>().Add(tournament);
                ctx.SaveChanges();
            }

            return(tournament);
        }
Esempio n. 11
0
        public Race CreateRace(Guid tournamentId, string track, int laps)
        {
            using (var ctx = new FormulaDContext(_options))
            {
                var race = new Race
                {
                    Id           = Guid.NewGuid(),
                    TournamentId = tournamentId,
                    Track        = track,
                    Laps         = laps,
                    RaceDate     = DateTime.Now
                };

                ctx.Set <Race>().Add(race);
                ctx.SaveChanges();

                return(race);
            }
        }