public void DeleteMatchPerson(MatchPerson matchPerson) { var clas = new Class1(); using (var session = clas.OpenSession()) { using (var transaction = session.BeginTransaction()) { session.Delete(matchPerson); transaction.Commit(); } } }
public MatchPerson GetPlayerForMatch(int matchId, int orgId, int playerId) { var result = new MatchPerson(); var clas = new Class1(); using (var session = clas.OpenSession()) { using (var transaction = session.BeginTransaction()) { try { result = session.QueryOver <MatchPerson>().Where(u => (u.Match.Id == matchId) && (u.Organization.Id == orgId) && (u.Person.Id == playerId)).List().FirstOrDefault(); } catch (Exception e) { } transaction.Commit(); } } return(result); }
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")); }
public void DeleteMatchPerson(MatchPerson matchPerson) { _matchRepository.DeleteMatchPerson(matchPerson); }
public void UpdateMatchPerson(MatchPerson matchPerson) { _matchRepository.UpdateMatchPerson(matchPerson); }
public MatchPerson RetrievePlayerForMatch(int matchId, int orgId, int playerId) { MatchPerson player = _matchRepository.GetPlayerForMatch(matchId, orgId, playerId); return(player); }