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); }
public ActionResult RegisterPlayer(int id = 0) { PlayerProcessor playerProcessor = new PlayerProcessor(); // Initialize new player, contract and healthCheck PlayerDetailsViewModel player = new PlayerDetailsViewModel(); player.player = new Person(); player.contract = new Contract(); player.healthCheck = new HealthCheckEvidention(); if (id != 0) { player.player = playerProcessor.RetrievePlayer(id); } return(View(player)); }
public ActionResult SignPlayers(List <PlayersStartSquad> model, FormCollection collection) { PlayerProcessor playerProcessor = new PlayerProcessor(); MatchProcessor matchProcessor = new MatchProcessor(); Organization org = Session["MyClub"] as Organization; foreach (var item in model) { Selection selection = new Selection(); var player = matchProcessor.RetrievePlayerForMatch(model.First().matchId, org.Id, item.playerId); if (item.isFirstSelection || item.isSubstitution) { if (player != null) { if (item.isFirstSelection) { selection = playerProcessor.RetrieveSelection(1); } else { selection = playerProcessor.RetrieveSelection(2); } player.Selection = selection; if (item.isFirstSelection && item.isCaptain) { player.Captain = 1; } matchProcessor.UpdateMatchPerson(player); } else { MatchPerson matchPerson = new MatchPerson(); matchPerson.Match = new Match(); matchPerson.Organization = new Organization(); matchPerson.Person = new Person(); matchPerson.Selection = new Selection(); if (item.isFirstSelection && item.isCaptain) { matchPerson.Captain = 1; } Person person = playerProcessor.RetrievePlayer(item.playerId); Match match = matchProcessor.RetrieveMatch(item.matchId); if (item.isFirstSelection) { selection = playerProcessor.RetrieveSelection(1); } else { selection = playerProcessor.RetrieveSelection(2); } matchPerson.Person = person; matchPerson.Match = match; matchPerson.Selection = selection; matchPerson.Organization = org; matchProcessor.UpdateMatchPerson(matchPerson); } } else { if (player != null) { matchProcessor.DeleteMatchPerson(player); } } } return(RedirectToAction("Index")); }