public async Task <IActionResult> Edit(int id, [Bind("CompetitionTeamId,CompetitionId,TeamId,AdmittedId,ResultTime,Penalty,Position")] CompetitionTeam competitionTeam)
        {
            if (id != competitionTeam.CompetitionTeamId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(competitionTeam);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CompetitionTeamExists(competitionTeam.CompetitionTeamId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AdmittedId"]    = new SelectList(_context.Admitions, "AdmittedId", "Name", competitionTeam.AdmittedId);
            ViewData["CompetitionId"] = new SelectList(_context.Competitions, "CompetitionId", "Name", competitionTeam.CompetitionId);
            ViewData["TeamId"]        = new SelectList(_context.Teams, "TeamId", "Comment", competitionTeam.TeamId);
            return(View(competitionTeam));
        }
        public IActionResult AddPartisipant(int idP, int idT, int idC)
        {
            var temp = _context.CompetitionTeams.FirstOrDefault(a => a.CompetitionId == idC && a.TeamId == idT);

            if (temp == null)
            {
                temp               = new CompetitionTeam();
                temp.TeamId        = idT;
                temp.CompetitionId = idC;
                temp.IsDeleted     = 0;
                _context.CompetitionTeams.Add(temp);
            }
            var temp1 = _context.TeamPartisipants.FirstOrDefault(a => a.TeamId == idT && a.PartisipantId == idP);

            if (temp1 == null)
            {
                temp1               = new TeamPartisipant();
                temp1.TeamId        = idT;
                temp1.PartisipantId = idP;
                _context.TeamPartisipants.Add(temp1);
            }
            temp1.IsDeleted    = 0;
            temp1.Participated = 1;
            _context.SaveChanges();
            return(RedirectToAction("CreateTeam", "Main", new { idCT = temp.CompetitionTeamId, id = idC }));
        }
Esempio n. 3
0
 public TeamRanking(int rank, string group, CompetitionTeam team, int groupLevel)
 {
     Rank            = rank;
     GroupName       = group;
     CompetitionTeam = team;
     GroupLevel      = groupLevel;
 }
Esempio n. 4
0
        public virtual void Update(CompetitionTeam compTeam)
        {
            CompetitionsTeams compTeamToUpdate = _mapper.Map <CompetitionTeam, CompetitionsTeams>(compTeam);

            _context.CompetitionsTeams.Attach(compTeamToUpdate);
            _context.Entry(compTeamToUpdate).State = EntityState.Modified;
        }
Esempio n. 5
0
        public void ShouldExerciseCompetitionTeamRepositoryNHibernate()
        {
            var repo     = new CompetitionTeamRepository(new RepositoryNHibernate <CompetitionTeam>());
            var compRepo = new CompetitionRepository(new RepositoryNHibernate <Competition>());

            var comp1 = new Season(null, "Season 1", 1, null, null, null, null, false, false, 1, null);
            var comp2 = new Playoff(null, "Playoff 1", 1, 1, null, null, null, null, false, false, 1, null);

            compRepo.Update(comp1);
            compRepo.Update(comp2);

            for (int i = 0; i < 10; i++)
            {
                var syt = new CompetitionTeam(comp1, null, "Team " + i, null, null, 5, null, 1, null);
                repo.Update(syt);
            }

            for (int i = 0; i < 5; i++)
            {
                var syt = new CompetitionTeam(comp2, null, "Team " + (i * 100), null, null, 5, null, 1, null);
                repo.Update(syt);
            }

            //can we get them all?
            var teams = repo.GetAll().ToList();
            var test  = teams.Where(t => t.Competition.Id == comp1.Id).ToList();

            StrictEqual(15, teams.Count);
            teams = repo.GetByCompetition(comp1).ToList();
            StrictEqual(10, teams.Count());
            teams = repo.GetByCompetition(comp2).ToList();
            StrictEqual(5, teams.Count());
        }
        private void GenerateTeamCompetition(int idCompetition, int idTeam)
        {
            CompetitionTeam compTeam = new CompetitionTeam
            {
                CompetitionId = idCompetition,
                TeamId        = idTeam
            };

            _unitOfWork.CompetitionTeamRepository.Insert(compTeam);
        }
Esempio n. 7
0
 public ScheduleGame(Competition competition, int gameNumber, int day, int year, Team homeTeam, CompetitionTeam homeCompetitionTeam, Team awayTeam, CompetitionTeam awayCompetitionTeam, int homeScore, int awayScore, bool complete, int currentPeriod, int currentTime, GameRules rules, bool processed)
     : base(homeTeam, awayTeam, rules, homeScore, awayScore, complete, currentPeriod, currentTime)
 {
     Competition         = competition;
     GameNumber          = gameNumber;
     Day                 = day;
     Year                = year;
     Processed           = processed;
     CompetitionHomeTeam = homeCompetitionTeam;
     CompetitionAwayTeam = awayCompetitionTeam;
 }
Esempio n. 8
0
        //override this for competition game players
        public virtual IList <GamePlayer> SetupCompetitionPlayers(CompetitionTeam team)
        {
            var result = new List <GamePlayer>();

            team.Players.ToList().ForEach(player =>
            {
                result.Add(
                    new CompetitionGamePlayer(this, player.Parent, team.Parent, player.FirstYear, player, team)
                    );
            });

            return(result);
        }
        public async Task <IActionResult> Create([Bind("CompetitionTeamId,CompetitionId,TeamId,AdmittedId,ResultTime,Penalty,Position")] CompetitionTeam competitionTeam)
        {
            if (ModelState.IsValid)
            {
                _context.Add(competitionTeam);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AdmittedId"]    = new SelectList(_context.Admitions, "AdmittedId", "Name", competitionTeam.AdmittedId);
            ViewData["CompetitionId"] = new SelectList(_context.Competitions, "CompetitionId", "Name", competitionTeam.CompetitionId);
            ViewData["TeamId"]        = new SelectList(_context.Teams, "TeamId", "Name", competitionTeam.TeamId);
            return(View(competitionTeam));
        }
Esempio n. 10
0
        private async Task SetUpPlayerCountScenario()
        {
            var testCompetition = new Competition
            {
                Code = "testCompetition",
                Name = "Test Competition"
            };

            var testTeam = new Team
            {
                Code    = "testTeam",
                Name    = "Test Team",
                Players = new List <Player>
                {
                    new Player
                    {
                        Code = "p1",
                        Name = "Player 1"
                    },
                    new Player
                    {
                        Code = "p2",
                        Name = "Player 2"
                    }
                }
            };

            var competitionTeam = new CompetitionTeam
            {
                Competition = testCompetition,
                Team        = testTeam
            };

            await _dbContext.Competitions.AddAsync(testCompetition);

            await _dbContext.Teams.AddAsync(testTeam);

            await _dbContext.CompetitionTeams.AddAsync(competitionTeam);

            await _dbContext.SaveChangesAsync();
        }
        public IActionResult CreateTeam(CreateTeam items)
        {
            var temp1 = _context.CompetitionTeams.FirstOrDefault(a => a.CompetitionId == items.competition.CompetitionId && a.TeamId == items.team.TeamId);

            if (temp1 == null)
            {
                temp1 = new CompetitionTeam();
                temp1.CompetitionId = items.competition.CompetitionId;
                temp1.TeamId        = items.team.TeamId;
                temp1.CompetitionId = items.competition.CompetitionId;
                temp1.AdmittedId    = Dict.ListAdmitions.FirstOrDefault(a => a.Name.Contains("не допущено")).ID;
                _context.CompetitionTeams.Add(temp1);
            }
            temp1.IsDeleted     = 0;
            temp1.CompetitionId = items.competition.CompetitionId;
            temp1.TeamId        = items.team.TeamId;

            var temp2 = _context.Teams.FirstOrDefault(a => a.TeamId == items.team.TeamId);

            temp2.IsDeleted = 0;
            temp2.Name      = items.team.Name;
            temp2.Comment   = items.team.Comment == null?"":items.team.Comment;
            _context.SaveChanges();
            if (items.back == 0)
            {
                return(RedirectToAction("Competition", "Main", new { id = items.competition.CompetitionId }));
            }
            if (items.back == 1)
            {
                return(RedirectToAction("RemovePartisipant", "Main", new { id = items.idP, idC = items.competition.CompetitionId, idT = items.team.TeamId }));
            }
            if (items.back == 2)
            {
                return(RedirectToAction("ListPartisipants", "Main", new { idC = items.competition.CompetitionId, idT = items.team.TeamId }));
            }
            return(RedirectToAction("Competition", "Main", new { id = items.competition.CompetitionId }));;
        }
Esempio n. 12
0
        public async Task <Competition> CreateFullCompetitionAsync(Competition competition, ICollection <Team> teams = null)
        {
            await this.unitOfWork.Competitions.AddAsync(competition);

            foreach (var team in teams ?? new List <Team>())
            {
                var dbTeam = await this.unitOfWork.Teams.GetByIdServiceAsync(team.IdService);

                if (dbTeam != null)
                {
                    var newCompetitionTeam = new CompetitionTeam
                    {
                        Team        = dbTeam,
                        Competition = competition
                    };
                    await this.unitOfWork.CompetitionTeams.AddAsync(newCompetitionTeam);

                    continue;
                }

                var competitionTeam = new CompetitionTeam
                {
                    Team        = team,
                    Competition = competition
                };
                await this.unitOfWork.CompetitionTeams.AddAsync(competitionTeam);

                await this.unitOfWork.Teams.AddAsync(team);

                await this.unitOfWork.Players.AddRangeAsync(team.Squad);
            }

            await this.unitOfWork.CommitAsync();

            return(competition);
        }
Esempio n. 13
0
 public virtual CompetitionPlayer CreateCompetitionPlayer(Competition competition, Player parent, CompetitionTeam competitionTeam)
 {
     return(new CompetitionPlayer(parent, competition, competitionTeam, new PlayerStats(), parent.Name, parent.Age, parent.Offense, parent.Defense, parent.Goaltending, competition.Year, competition.Year));
 }
Esempio n. 14
0
 public PlayoffGame(Competition competition, PlayoffSeries series, int gameNumber, int day, int year, Team homeTeam, CompetitionTeam homeCompetitionTeam,
                    Team awayTeam, CompetitionTeam awayCompetitionTeam, int homeScore, int awayScore, bool complete, int currentPeriod, int currentTime, GameRules rules, bool processed)
     : base(competition, gameNumber, day, year, homeTeam, homeCompetitionTeam, awayTeam, awayCompetitionTeam, homeScore, awayScore, complete, currentPeriod, currentTime, rules, processed)
 {
     Series = series;
 }
Esempio n. 15
0
        public virtual void Insert(CompetitionTeam compTeam)
        {
            CompetitionsTeams compTeamDB = _mapper.Map <CompetitionTeam, CompetitionsTeams>(compTeam);

            _context.CompetitionsTeams.Add(compTeamDB);
        }