public void Handle(LeaveLeagueCommand command) { // TODO validate using (var dbContext = new ManagementDataContext()) { Team team = dbContext.Teams.SingleOrDefault(t => t.Id == command.TeamId); if (team == null) { throw new ServerSideException("Ups, something went wrong! Refresh page and try agine"); } League league = dbContext.Leagues.SingleOrDefault(l => l.Teams.Contains(team)); if (league == null) { throw new ServerSideException("Ups, something went wrong! Refresh page and try agine"); } team.LeaveLeague(league); dbContext.SaveChanges(); } }
public void Handle(SendMessageCommand command) { // TODO validate using (var dbContext = new ManagementDataContext()) { // TODO dbContext.SaveChanges(); } }
public void Handle(RemoveTeamCommand command) { // TODO validate using (var dbContext = new ManagementDataContext()) { Team team = dbContext.Teams.SingleOrDefault(l => l.ManagerId == command.Id); dbContext.Teams.Remove(team); dbContext.SaveChanges(); } }
public void Handle(RemovePlayerCommand command) { // TODO validate using (var dbContext = new ManagementDataContext()) { Player player = dbContext.Players.SingleOrDefault(l => l.Id == command.PlayerId); dbContext.Players.Remove(player); dbContext.SaveChanges(); } }
public void Handle(CreateTeamCommand command) { // TODO validate using (var dbContext = new ManagementDataContext()) { Team team = CreateTeamEntity(command); dbContext.Teams.Add(team); dbContext.SaveChanges(); } }
public void Handle(RemoveLeagueCommand command) { // TODO validate using (var dbContext = new ManagementDataContext()) { League league = dbContext.Leagues.FirstOrDefault(l => l.OrganizerId == command.Id); dbContext.Leagues.Remove(league); dbContext.SaveChanges(); } }
public void Handle(CreateLeagueCommand command) { // TODO validate using (var dbContext = new ManagementDataContext()) { League league = CreateLeagueEntity(command); dbContext.Leagues.Add(league); dbContext.SaveChanges(); } }
public void Handle(AddPlayerCommand command) { // TODO validate using (var dbContext = new ManagementDataContext()) { Team team = dbContext.Teams.SingleOrDefault(l => l.Id == command.TeamId); Player player = CreatePlayerEntity(command, team); dbContext.Players.Add(player); dbContext.SaveChanges(); } }
public void Handle(AddLeagueNoteCommand command) { // TODO validate using (var dbContext = new ManagementDataContext()) { League league = dbContext.Leagues.SingleOrDefault(l => l.Id == command.LeagueId); LeagueNote note = CreateNoteEntity(command, league); dbContext.LeagueNotes.Add(note); dbContext.SaveChanges(); } }
public void Handle(JoinLeagueCommand command) { // TODO validate using (var dbContext = new ManagementDataContext()) { League league = dbContext.Leagues.SingleOrDefault(l => l.Id == command.LeagueId); Team team = dbContext.Teams.SingleOrDefault(l => l.Id == command.TeamId); JoinToLeague(league, team); dbContext.SaveChanges(); } }
public void Handle(UpdateCoachCommand command) { // TODO validate using (var dbContext = new ManagementDataContext()) { Team team = dbContext.Teams.SingleOrDefault(l => l.Id == command.TeamId); if (team == null || team.Coach == null) { throw new ServerSideException("Ups, something went wrong! Refresh page and try agine"); } UpdateCoach(team.Coach, command); dbContext.SaveChanges(); } }
public void Handle(UpdateRegulationsCommand command) { // TODO validate using (var dbContext = new ManagementDataContext()) { League league = dbContext.Leagues.SingleOrDefault(l => l.Id == command.LeagueId); if (league == null || league.Regulations == null) { throw new ServerSideException("Ups, something went wrong! Refresh page and try agine"); } UpdateRegulations(league.Regulations, command); dbContext.SaveChanges(); } }
public void Handle(UpdateTeamStatusCommand command) { // TODO validate using (var dbContext = new ManagementDataContext()) { League league = dbContext.Leagues.SingleOrDefault(l => l.Id == command.LeagueId); Team team = dbContext.Teams.SingleOrDefault(l => l.Id == command.TeamId); if (league == null || league.TeamsWaitingForApprove == null) { throw new ServerSideException("Ups, something went wrong! Refresh page and try agine"); } if (team == null) { throw new ServerSideException("Ups, something went wrong! Refresh page and try agine"); } UpdateTeamStatus(league, team, command.Accept); dbContext.SaveChanges(); } }