public void CanRemoveBracketRoundFromTournamentById() { List <Guid> roundIds = new List <Guid>(); using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName); RoundBase round = tournamentRepository.AddBracketRoundToTournament(tournament); roundIds.Add(round.Id); round = tournamentRepository.AddDualTournamentRoundToTournament(tournament); roundIds.Add(round.Id); round = tournamentRepository.AddRoundRobinRoundToTournament(tournament); roundIds.Add(round.Id); tournamentRepository.Save(); } using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName); foreach (Guid roundId in roundIds) { bool removeResult = tournamentRepository.RemoveRoundFromTournament(tournament, roundId); tournamentRepository.Save(); removeResult.Should().BeTrue(); } tournament.Rounds.Should().BeEmpty(); } }
static void Main(string[] args) { Config.Load(args); var id_provider = new IdProvider(); var date_provider = new DateProvider(); var person_repo = new PersonRepository(Config.DbPath); var tournament_repo = new TournamentRepository(Config.DbPath); var director = new TournamentDirector(id_provider); var personStockQueryHandler = new PersonStockQueryHandler(person_repo); var newPersonQueryHandler = new NewPersonQueryHandler(id_provider); var storePersonCommandHandler = new StorePersonCommandHandler(person_repo); var createTournamentCommandHandler = new CreateTournamentCommandHandler(tournament_repo, person_repo, id_provider, date_provider, director); var tournamentQueryHandler = new TournamentQueryHandler(tournament_repo); var tournamentsInfoQueryHandler = new TournamentStockQueryHandler(tournament_repo); var server = new Server(personStockQueryHandler, newPersonQueryHandler, storePersonCommandHandler, createTournamentCommandHandler, tournamentQueryHandler, tournamentsInfoQueryHandler); server.Run(Config.Address); }
public StudentsModel(ApplicationDbContext context) { this.context = context; tournamentRepository = new TournamentRepository(this.context); userRepository = new ApplicationUserRepository(this.context); studentTournamentRepository = new StudentTournamentRepository(this.context); }
private static void Main() { var dbContextFactory = new KandandaDatabaseContextFactory(); var pluralizationService = new EnglishPluralizationService(); var tournamentRepository = new TournamentRepository(dbContextFactory, pluralizationService); var participantRepository = new ParticipantRepository(dbContextFactory, pluralizationService); var newTournament = new Tournament { Name = "Schweizermeisterschaft" }; var newParticipant = new Participant { Name = "FC St. Gallen" }; newTournament.Participants.Add(newParticipant); tournamentRepository.Save(newTournament); List <Participant> participants = participantRepository.GetAll(); foreach (Participant participant in participants) { Console.WriteLine($"{participant.Id} {participant.Name}"); } Console.ReadKey(); }
private void LoadTournament() { Log.Debug("Loading tournament..."); TournamentRepository tournamentRepository = new TournamentRepository(); if (SelectedFile != null) { Tournament tournament = tournamentRepository.LoadTournamentFromXML(SelectedFile.RecentFile.FullName); var tournamentViewModel = new TournamentViewModel(tournament, SelectedFile.RecentFile.FullName); Messenger.Default.Send(new NotificationMessage <ViewModelBase>(this, tournamentViewModel, "TournamentViewModel")); } else { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = "Open XML bestand"; openFileDialog.DefaultExt = ".xml"; openFileDialog.Filter = "XML documents (.xml)|*.xml"; openFileDialog.CheckFileExists = true; openFileDialog.CheckPathExists = true; if (openFileDialog.ShowDialog() == true) { Tournament tournament = tournamentRepository.LoadTournamentFromXML(openFileDialog.FileName); var tournamentViewModel = new TournamentViewModel(tournament); Messenger.Default.Send(new NotificationMessage <ViewModelBase>(this, tournamentViewModel, "TournamentViewModel")); } } //Making it null again in case we want to access the method out of the first window (for example starting a new tournament while in the tournamentViewModel) //If we don't do this, we always get in the first if and it will always open the tournament that was originally selected. SelectedFile = null; }
public void CanRenamePlayerReferenceInTournament() { InitializeRoundGroupAndPlayers(); string oldName = playerNames.First(); string newName = oldName + "-san"; using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName); PlayerReference playerReference = tournament.GetPlayerReferenceByName(oldName); tournamentRepository.RenamePlayerReferenceInTournament(playerReference, newName); tournamentRepository.Save(); } using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName); PlayerReference playerReference = tournament.GetPlayerReferenceByName(newName); playerReference.Should().NotBeNull(); playerReference.Name.Should().Be(newName); } }
public GroupType(GroupRepository groupRepository, TournamentRepository tournamentRepository) { Field(x => x.Id, type: typeof(IdGraphType)); Field(x => x.Name, nullable: true).Description("The name of the group"); Field(x => x.DisplayName, nullable: true).Description("The display name of the group that should be used in app UI"); Field(x => x.TournamentId, type: typeof(IdGraphType), nullable: true); Field <TournamentType>( "tournament", resolve: context => { if (context.Source.TournamentId != null) { return(tournamentRepository.GetById((Guid)context.Source.TournamentId)); } return(null); } ); Field <ListGraphType <PlayerType> >( "players", resolve: context => groupRepository.GetPlayersOfGroupById(context.Source.Id) ); Field <ListGraphType <FrameType> >( "frames", resolve: context => groupRepository.GetFramesOfGroupById(context.Source.Id) ); }
public HttpResponseMessage ListAll() { try { List <TournamentModelGet> list = new List <TournamentModelGet>(); TournamentRepository rep = new TournamentRepository(); foreach (Tournament t in rep.ListAll()) { TournamentModelGet model = new TournamentModelGet(); model.Tournament_ID = t.Tournament_ID; model.Name = t.Name; model.NumberOfTeams = t.NumberOfTeams; model.Start = t.Start; list.Add(model); } return(Request.CreateResponse(HttpStatusCode.OK, list)); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message)); } }
public HttpResponseMessage Add(TournamentModelAdd model) { if (ModelState.IsValid) { try { Tournament t = new Tournament(); t.Name = model.Name; t.NumberOfTeams = model.NumberOfTeams; t.Start = model.Start; TournamentRepository rep = new TournamentRepository(); rep.Insert(t); return(Request.CreateResponse(HttpStatusCode.OK, "")); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message)); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } }
public async Task <Tournament> PostAsync([FromBody] Tournament tournament) { var TournamentRep = new TournamentRepository(_db); var result = await TournamentRep.SaveTournament(tournament); return(result); }
public async Task <List <Tournament> > Delete(int id) { var TournRep = new TournamentRepository(_db); var Result = await TournRep.DeleteTournament(id); return(Result); }
public EditModel(ApplicationDbContext context) { this.context = context; tournamentRepository = new TournamentRepository(this.context); userRepository = new ApplicationUserRepository(this.context); taskRepository = new TournamentTaskRepository(this.context); }
public void GivenATournamentNamedWithUsersAddedToIt(string tournamentName, string commaSeparatedUserNames) { List <string> userNames = StringUtility.ToStringList(commaSeparatedUserNames, ","); using (UserRepository userRepository = CreateuserRepository()) { foreach (string userName in userNames) { userRepository.CreateUser(userName); } userRepository.Save(); using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { Tournament tournament = tournamentRepository.CreateTournament(tournamentName); foreach (string userName in userNames) { User user = userRepository.GetUserByName(userName); tournamentRepository.AddBetterToTournament(tournament, user); } tournamentRepository.Save(); } } }
private static void Main(string[] args) { ITournamentRepository repo = new TournamentRepository(); Tournament tournament2 = repo.LoadCurrentTournement(); if (TournamentFinished(tournament2)) { tournament2 = CreateNew(tournament2, GeneratePlayers()); repo.SaveTournementAsCurrent(tournament2); } Process started = Process.Start("C:\\Program Files (x86)\\Kickertool\\Kickertool.exe"); bool watch = true; bool turnamentRunning2 = false; while (watch) { Process[] processes = Process.GetProcesses(); turnamentRunning2 = ((IEnumerable <Process>)processes).Any((Func <Process, bool>)((Process x) => x.ProcessName.ToLower() == "kickertool")); if (turnamentRunning2) { Thread.Sleep(1000); } if (!turnamentRunning2) { tournament2 = repo.LoadCurrentTournement(); if (tournament2.ko != null && ((tournament2.ko?.levels?.FirstOrDefault((Func <Level, bool>)((Level x) => x.name == "1/1"))?.plays.FirstOrDefault())?.valid ?? false)) { int debug = 2; } } } }
public void WhenMatchesInTournamentNamedSwitchesPlayerReferences(string tournamentName, Table table) { using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName); foreach (TableRow row in table.Rows) { ParsePlayerSwitch(row, out int roundIndex, out int groupIndex1, out int matchIndex1, out string playerName1, out int groupIndex2, out int matchIndex2, out string playerName2); RoundBase roundBase = tournament.Rounds[roundIndex]; GroupBase groupBase1 = roundBase.Groups[groupIndex1]; Match match1 = groupBase1.Matches[matchIndex1]; Player player1 = match1.FindPlayer(playerName1); GroupBase groupBase2 = roundBase.Groups[groupIndex2]; Match match2 = groupBase2.Matches[matchIndex2]; Player player2 = match2.FindPlayer(playerName2); tournamentRepository.SwitchPlayersInMatches(player1, player2); } tournamentRepository.Save(); } }
public TournamentRepository GetTournamentRepository() { if (tournamentRepository == null) { tournamentRepository = new TournamentRepository(); } return(tournamentRepository); }
public void ShouldGetTournaments() { var sut = new TournamentRepository(); var tournaments = sut.Retrieve(); Assert.That(tournaments.Count, Is.GreaterThan(0)); }
public void CannotCreateTournamentWithNameAlreadyInUseNoMatterLetterCasing() { using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { Tournament secondTournament = tournamentRepository.CreateTournament(tournamentName.ToUpper()); secondTournament.Should().BeNull(); } }
public void ShouldGetOneTournament() { var sut = new TournamentRepository(); var tournament = sut.Retrieve(1); Assert.That(tournament, Is.Not.Null); Assert.That(tournament.TournamentId, Is.EqualTo(1)); }
public UnitOfWork(ApplicationContext context) { _context = context; ApplicationUsers = new ApplicationUserRepository(_context); Tournaments = new TournamentRepository(_context); Matches = new MatchRepository(_context); Teams = new TeamRepository(_context); Players = new PlayerRepository(_context); }
public void IniclizeManagers() { IUserRepository userRepo = new UserRepository(); ITournamentRepository tourRepo = new TournamentRepository(); _programManager = new ProgramManager(); _tournamentManager = new TournamentManager(tourRepo); _userManager = new UserManager(userRepo); }
public UnitOfWork(TsContext context) { _context = context; Tournaments = new TournamentRepository(_context); Teams = new TeamRepository(_context); Persons = new PersonRepository(_context); Players = new PlayerRepository(_context); Courts = new CourtRepository(_context); }
public void CannotRenameNonexistingTournament() { using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { bool renameResult = tournamentRepository.RenameTournament(Guid.NewGuid(), "BHA Open 2019"); renameResult.Should().BeFalse(); } }
public void CanGetTournamentByName() { using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName); tournament.Name.Should().Be(tournamentName); } }
public void GivenRoundNamedIsRemovedFromTournamentNamed(string roundName, string tournamentName) { using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { Tournament tournament = tournamentRepository.GetTournamentByName(tournamentName); tournamentRepository.RemoveRoundFromTournament(tournament, roundName); tournamentRepository.Save(); } }
public TournamentRepositoryTestBase() { testDatabaseName = Guid.NewGuid().ToString(); using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { tournamentRepository.CreateTournament(tournamentName); tournamentRepository.Save(); } }
public DetailsModel(ApplicationDbContext context, LocService locService) { this.context = context; taskRepository = new TournamentTaskRepository(this.context); tournamentRepository = new TournamentRepository(this.context); processManager = new ProcessManager(this); storageManager = new StorageManager(); processResultHelper = new ProcessResultHelper(locService); }
//TODO Repositories solution: We shouldn't create them each time we need them. Can we make them accesible everywhere somehow? i.e static class controller? /// <summary> /// This method is responsible for saving a tournament to a certain path. /// TODO Should we insert a recent file here or automaticly when we save a tournament, so in the tournament repository. /// </summary> /// <param name="uri"></param> private void Save(string uri) { Log.Debug(uri); RecentFileRepository recentFileRepository = new RecentFileRepository(); TournamentRepository tournamentRepository = new TournamentRepository(); tournamentRepository.SaveTournamentAsXML(CurrentTournament, uri); recentFileRepository.InsertFile(uri); }
public TournamentBLL( TournamentRepository tournamentRepository, PlayerTournamentRepository playerTournamentRepository, PlayerPositionTournamentRepository playerPositionTournamentRepository ) { this.tournamentRepository = tournamentRepository; this.playerTournamentRepository = playerTournamentRepository; this.playerPositionTournamentRepository = playerPositionTournamentRepository; }
public UnitOfWork(ApplicationDbContext context) { _context = context; Tournaments = new TournamentRepository(context); Participations = new ParticipationRepository(context); Games = new GameRepository(context); Notifications = new NotificationRepository(context); UserNotifications = new UserNotificationRepository(context); CreditCards = new CreditCardRepository(context); }
public TournamentRepository GetTournamentRepository() { if(tournamentRepository == null) { tournamentRepository = new TournamentRepository(); } return tournamentRepository; }