Exemple #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            //var connection = "Server=PCPQ\\SQLEXPRESS;Database=ATATENNIS;Trusted_Connection=True;";

            var optionsBuilder = new DbContextOptionsBuilder <AtaTennisContext>();

            optionsBuilder.UseSqlServer(connection);

            var context = new AtaTennisContext();

            DbInitializer.Initialize(context);

            var player = context.Players.FirstOrDefault();

            //player.Wait();
            //Console.WriteLine(player.Result.Age + player.Result.Name + ' ' + player.Result.Surname);
            Console.WriteLine(player.BirthDate + player.Name + ' ' + player.Surname);

            //var user = new UserDTO(){
            //    //Email = "",
            //    Password = "******",
            //    Username = "******"
            //};
            //var userService = new UserService(context);
            //Task.WaitAll(userService.CreateAsync(user));

            Console.ReadLine();
        }
Exemple #2
0
        public UserController(AtaTennisContext dbContext, IOptions <AppSettings> appSettings)
        {
            _dbContext   = dbContext;
            _userService = new UserService(_dbContext);
            _appSettings = appSettings.Value;

            _mapper = MapperHelper.GetUserMapper();
        }
Exemple #3
0
 public MatchService(AtaTennisContext context)
 {
     _dbContext = context;
 }
Exemple #4
0
 public UserService(AtaTennisContext context)
 {
     dbContext = context;
 }
Exemple #5
0
 public TournamentService(AtaTennisContext context)
 {
     _dbContext = context;
 }
Exemple #6
0
 public PlayerService(AtaTennisContext context)
 {
     _dbContext = context;
 }
 public TournamentController(AtaTennisContext dbContext)
 {
     _dbContext        = dbContext;
     TournamentService = new TournamentService(dbContext);
 }
 public QualificationMatchController(AtaTennisContext dbContext)
 {
     MatchService = new MatchService(dbContext);
 }
Exemple #9
0
 public MatchController(AtaTennisContext dbContext)
 {
     MatchService = new MatchService(dbContext);
 }
Exemple #10
0
 public PlayerController(AtaTennisContext dbContext)
 {
     _dbContext    = dbContext;
     PlayerService = new PlayerService(_dbContext);
 }
Exemple #11
0
        public static void Initialize(AtaTennisContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Players.Any() && context.Tournaments.Any() && context.Users.Any() && context.TournamentEntries.Any())
            {
                return;   // DB has been seeded
            }

            var players = new Player[]
            {
                new Player {
                    BirthDate = new DateTime(1988, 5, 5), Name = "Peter", Surname = "Sveter", Points = 450,
                    Backhand  = Backhand.oneHanded, FavouritePlayer = "Roger", Forehand = Forehand.rightHanded,
                    Height    = 175, Weight = 70, Racquet = "Wilson Blade", Residence = "Spisska Nova Ves", Surface = SurfaceType.clay
                },
                new Player {
                    BirthDate = new DateTime(1994, 3, 8), Name = "Jano", Surname = "Slany", Points = 50,
                    Backhand  = Backhand.twoHanded, FavouritePlayer = "Delpo", Forehand = Forehand.rightHanded,
                    Height    = 185, Weight = 78, Racquet = "Babolat", Residence = "Nitra", Surface = SurfaceType.grass
                },
                new Player {
                    BirthDate = new DateTime(1978, 4, 7), Name = "Miso", Surname = "Sef", Points = 220,
                    Backhand  = Backhand.twoHanded, FavouritePlayer = "Rafa", Forehand = Forehand.rightHanded,
                    Height    = 181, Weight = 82, Racquet = "Babolat", Residence = "Blava", Surface = SurfaceType.grass
                },
                new Player {
                    BirthDate = new DateTime(1969, 2, 2), Name = "Jozo", Surname = "Suly", Points = 185,
                    Backhand  = Backhand.twoHanded, FavouritePlayer = "Delpo", Forehand = Forehand.rightHanded,
                    Height    = 185, Weight = 96, Racquet = "Babolat", Residence = "Nitra", Surface = SurfaceType.grass
                },
            };

            foreach (Player p in players)
            {
                context.Players.Add(p);
            }

            if (context.Tournaments.Any())
            {
                return;
            }

            var tournaments = new Tournament[]
            {
                new Tournament {
                    Category       = TournamentCategory.singles,
                    BallsType      = BallsType.slazenger,
                    Description    = "wimbledon summer challange dufajme za pekneho letneho pocasia...",
                    DrawType       = DrawType.playoff,
                    Name           = "Wimbledon Challange",
                    Place          = "Kopčany",
                    PlayingSystem  = PlayingSystem.prince,
                    TournamentType = TournamentType.challangerSpecial,
                    StartTime      = new DateTime(2019, 7, 12),
                    Surface        = SurfaceType.grass
                },
                new Tournament {
                    Category       = TournamentCategory.singles,
                    BallsType      = BallsType.dunlop,
                    Description    = "Areal nitrianskeho futbaloveho stadiona",
                    DrawType       = DrawType.playoff,
                    Name           = "Temprim CUP",
                    Place          = "Nitra",
                    PlayingSystem  = PlayingSystem.prince,
                    TournamentType = TournamentType.challanger,
                    StartTime      = new DateTime(2019, 1, 19),
                    Surface        = SurfaceType.clay
                },
                new Tournament {
                    Category       = TournamentCategory.singles,
                    BallsType      = BallsType.slazenger,
                    Description    = "wimbledon summer challange dufajme za pekneho letneho pocasia...",
                    DrawType       = DrawType.playoff,
                    Name           = "Senica OPEN",
                    Place          = "Senica",
                    PlayingSystem  = PlayingSystem.prince,
                    TournamentType = TournamentType.ata,
                    StartTime      = new DateTime(2019, 8, 2),
                    EndTime        = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 3),
                    Surface        = SurfaceType.clay
                },
                new Tournament {
                    Category       = TournamentCategory.singles,
                    BallsType      = BallsType.dunlop,
                    Description    = "wimbledon summer challange dufajme za pekneho letneho pocasia...",
                    DrawType       = DrawType.playoff,
                    Name           = "Summer Cup Open",
                    Place          = "Břeclav",
                    PlayingSystem  = PlayingSystem.prince,
                    TournamentType = TournamentType.challanger,
                    StartTime      = new DateTime(2019, 9, 12),
                    EndTime        = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 13),
                    Surface        = SurfaceType.clay
                }
            };

            foreach (var tournament in tournaments)
            {
                context.Tournaments.Add(tournament);
            }

            if (context.Users.Any())
            {
                return;
            }

            var admin = new User {
                Username = "******", Password = "******", Email = ""
            };

            context.Users.Add(admin);

            var tournamentEntries = new TournamentEntry[]
            {
                new TournamentEntry
                {
                    PlayerId     = 1,
                    TournamentId = 1
                },
                new TournamentEntry
                {
                    PlayerId     = 2,
                    TournamentId = 1
                },
                new TournamentEntry
                {
                    PlayerId     = 4,
                    TournamentId = 1
                }
            };

            foreach (var tournamentEntry in tournamentEntries)
            {
                context.TournamentEntries.Add(tournamentEntry);
            }

            context.SaveChanges();
        }