示例#1
0
        public PlayerDetailsViewModel RetrievePlayer(int id)
        {
            var playerProcessor = new PlayerProcessor();
            var player          = new PlayerDetailsViewModel();

            player.player      = new Person();
            player.contract    = new Contract();
            player.healthCheck = new HealthCheckEvidention();

            try
            {
                var myPlayer = playerProcessor.RetrievePlayerDetails(id);
                player.player = playerProcessor.RetrievePlayer(myPlayer.Id);
                if (myPlayer.ContractId != 0 && myPlayer.ContractId != null)
                {
                    player.contract = playerProcessor.RetrieveContract(myPlayer.ContractId);
                }
                if (myPlayer.HealthCheckId != 0 && myPlayer.HealthCheckId != null)
                {
                    player.healthCheck = playerProcessor.RetrieveHealthCheck(myPlayer.HealthCheckId);
                }
            }

            catch (Exception e)
            {
                player = null;
            }

            return(player);
        }
示例#2
0
        // GET: Match/SignPlayer/5
        public ActionResult SignPlayers(int matchId)
        {
            List <PlayersStartSquad> model = new List <PlayersStartSquad>();
            var          playerDetails     = new PlayerDetails();
            var          matchProcessor    = new MatchProcessor();
            var          playerProcessor   = new PlayerProcessor();
            var          userProcessor     = new UserProcessor();
            Organization org = Session["MyClub"] as Organization;

            var players     = matchProcessor.RetrievePlayersForMatch(matchId, org.Id);
            var clubPlayers = userProcessor.GetClubPlayers(org.Id);

            if (players.Count != 0)
            {
                foreach (var item in players)
                {
                    foreach (var clubPlayer in clubPlayers)
                    {
                        if (item.Person.Id == clubPlayer.Id)
                        {
                            PlayersStartSquad player = new PlayersStartSquad();
                            player.playerId       = item.Person.Id;
                            player.matchId        = matchId;
                            player.organizationId = org.Id;
                            playerDetails         = playerProcessor.RetrievePlayerDetails(item.Person.Id);
                            player.firstName      = playerDetails.FirstName;
                            player.lastName       = playerDetails.LastName;
                            player.numberOnShirt  = playerDetails.NumberOnShirt;

                            if (item.Selection.Id == 1)
                            {
                                player.isFirstSelection = true;
                            }
                            else if (item.Selection.Id == 2)
                            {
                                player.isSubstitution = true;
                            }
                            else
                            {
                                player.isFirstSelection = false;
                                player.isSubstitution   = false;
                            }

                            if (item.Captain == 0)
                            {
                                player.isCaptain = false;
                            }
                            else
                            {
                                player.isCaptain = true;
                            }

                            model.Add(player);
                        }
                    }
                }
                //return View(model);
            }
            foreach (var item in clubPlayers)
            {
                if (model.Find(x => x.playerId == item.Id) == null)
                {
                    PlayersStartSquad player = new PlayersStartSquad();
                    player.matchId        = matchId;
                    player.organizationId = org.Id;
                    player.playerId       = item.Id;
                    playerDetails         = playerProcessor.RetrievePlayerDetails(item.Id);
                    player.firstName      = playerDetails.FirstName;
                    player.lastName       = playerDetails.LastName;
                    player.numberOnShirt  = playerDetails.NumberOnShirt;
                    model.Add(player);
                }
            }
            return(View(model));
        }