public ActionResult ReplaceCompetitionPlayer(int competitionId, int replacedPlayerId, int replacementPlayerId, CompetitionPlayerSource source, CompetitionPlayerStatus status, string reason)
 {
     SystemMonitor.Info("Replaceing {0} with {1}", replacedPlayerId, replacementPlayerId);
     var manager = ServiceProvider.Get<ICompetitionsManager>();
     manager.ReplacePlayer(competitionId, replacedPlayerId, replacementPlayerId, source, status, reason);
     return new HttpStatusCodeResult(200);
 }
示例#2
0
        public ActionResult Create(int? competitionId, int? replacePlayerId, string idNumber, CompetitionPlayerSource? source, CompetitionSection? section, CompetitionPlayerStatus? status, string reason)
        {
            var player = new Player();
            var model = new CreatePlayerModel { Player = player };

            if (competitionId.HasValue)
            {
                var competitionRepository = ServiceProvider.Get<ICompetitionRepository>();
                model.Competition = competitionRepository.GetCompetition(competitionId.Value);
                model.Source = source.GetValueOrDefault(CompetitionPlayerSource.Regular);
                model.Section = section.GetValueOrDefault(CompetitionSection.Final);
                model.Status = status.GetValueOrDefault(CompetitionPlayerStatus.Active);
                model.Reason = reason;

                if (replacePlayerId.HasValue)
                {
                    var playersRepository = ServiceProvider.Get<IPlayersRepository>();
                    model.ReplacedPlayer = playersRepository.Get(replacePlayerId.Value);
                }
            }

            if (idNumber.NotNullOrEmpty())
            {
                model.Player.IdNumber = idNumber;
            }
            return View(model);
        }
示例#3
0
        public void RemovePlayer(int competitionId, int playerId, CompetitionPlayerStatus status, string reason)
        {
            var competitionsEngine = ServiceProvider.Get <ICompetitionsEngine>();

            competitionsEngine.RemovePlayerFromUnplayedMatches(competitionId, playerId);
            competitionsEngine.RemovePlayerFromCompetition(competitionId, playerId, status, reason);
        }
示例#4
0
        public void RemovePlayerFromCompetition(int competitionId, int playerId, CompetitionPlayerStatus status, string reason)
        {
            UseDataContext(dataContext =>
            {
                var relevantPlayers =
                    dataContext.CompetitionPlayers.Where(
                        cp => cp.CompetitionId == competitionId && cp.PlayerId == playerId);

                relevantPlayers.ForEach(
                    player =>
                {
                    player.Status = (int)status;
                    player.Reason = reason;
                });
                dataContext.SubmitChanges();
            });
        }
示例#5
0
        public ActionResult Create(int? competitionId, int? replacedPlayerId, Player player, CompetitionPlayerSource? competitionPlayerSource, CompetitionSection? competitionSection, CompetitionPlayerStatus? status, string reason)
        {
            var playersRepository = ServiceProvider.Get<IPlayersRepository>();
            var newPlayerId = playersRepository.Add(player);

            if (competitionId.HasValue)
            {
                var manager = ServiceProvider.Get<ICompetitionsManager>();
                if (replacedPlayerId.HasValue)
                {
                    manager.ReplacePlayer(competitionId.Value, replacedPlayerId.Value, newPlayerId, competitionPlayerSource.GetValueOrDefault(CompetitionPlayerSource.Regular), status.GetValueOrDefault(CompetitionPlayerStatus.Active), reason);
                }
                else
                {
                    manager.AddPlayerToCompetition(competitionId.Value, newPlayerId, competitionPlayerSource.GetValueOrDefault(CompetitionPlayerSource.Regular), competitionSection.GetValueOrDefault(CompetitionSection.Final));
                }
                return RedirectToAction("Details", "Competitions", new { id = competitionId.Value });
            }
            else
            {
                return RedirectToAction("Index");
            }
        }
示例#6
0
        public void RemovePlayerFromCompetition(int competitionId, int playerId, CompetitionPlayerStatus status, string reason)
        {
            var competitionRepository = ServiceProvider.Get <ICompetitionRepository>();

            competitionRepository.RemovePlayerFromCompetition(competitionId, playerId, status, reason);
        }
        public ActionResult ReplaceCompetitionPlayer(int competitionId, int replacedPlayerId, int replacementPlayerId, CompetitionPlayerSource source, CompetitionPlayerStatus status, string reason)
        {
            SystemMonitor.Info("Replaceing {0} with {1}", replacedPlayerId, replacementPlayerId);
            var manager = ServiceProvider.Get <ICompetitionsManager>();

            manager.ReplacePlayer(competitionId, replacedPlayerId, replacementPlayerId, source, status, reason);
            return(new HttpStatusCodeResult(200));
        }
 public ActionResult RemoveCompetitionPlayer(int competitionId, int playerId, CompetitionPlayerStatus? status, string reason)
 {
     var manager = ServiceProvider.Get<ICompetitionsManager>();
     manager.RemovePlayer(competitionId, playerId, status.GetValueOrDefault(CompetitionPlayerStatus.Removed), reason);
     return new HttpStatusCodeResult(200);
 }
示例#9
0
        public void ReplacePlayer(int competitionId, int replacedPlayerId, int replacingPlayerId, CompetitionPlayerSource source, CompetitionPlayerStatus status, string reason)
        {
            var competitionRepository = ServiceProvider.Get <ICompetitionRepository>();
            var player = competitionRepository.GetCompetitionPlayer(competitionId, replacedPlayerId);

            if (player.IsNull())
            {
                throw new ArgumentException("Cannot replace player, player does not exist.");
            }

            RemovePlayer(competitionId, replacedPlayerId, status, reason);
            AddPlayerToCompetition(competitionId, replacingPlayerId, source, player.Section);
        }