//Finding the player (RecipientID) by the invite and giving the player a new room as well. //Its roomid is assigned to the requested roomid and then we are updating the player's room to that which it has accepted. //After accepting, we remove the recent generated invite. public void acceptInvite(Invite invite) { using (InviteRepository inviteRepository = new InviteRepository("DefaultConnection")) { Player recipient = userLogic.findPLayer(invite.RecipientID); recipient.Room = new Room(); recipient.Room.ID = invite.Room_id; userLogic.updatePlayer(recipient); foreach (Player_Status status in Player_statusLogic.GetAllPlayerStatusForOnePLayer(recipient)) { Player_statusLogic.deletePlayerStatus(status); } Player_statusLogic.CreatePlayerStatusForARoom(recipient, recipient.Room); inviteRepository.removeInvite(invite.SenderID, invite.RecipientID); } }
//After registering, you direct to categories. //Finding the section by the id, and creating a room for that section. //Finding a player by its username and then assigning that player in a room . //After finding the section - creating the room and assigning the player in a room (updating the player's room). //For creating a room we need to know the sectionID and the userName who has chosen that. //We create a section and a room. public Room chooseSection(int id, string userName) { using (PlayerRepository playerRepository = new PlayerRepository("DefaultConnection")) { Section section = sectionLogic.findOneSection(id); Room room = new Room(0, section); roomLogic.createRoom(room); Player player = playerRepository.findOnePlayer(userName); player.Room = room; playerRepository.updatePlayer(player); player_status.CreatePlayerStatusForARoom(player, room); return(room); } }