public DTO.Player JoinLobby(DTO.Lobby lobby, DTO.Player player)
        {
            DTO.Player returnplay = new DTO.Player();
            try
            {
                if (player.IsHost == true)
                {
                    StopHost(player);
                }

                var join = (from l in db.Players
                            where l.PlayerId == player.PlayerId
                            select l).First();

                var isthere = (from l in db.Lobbis
                               where l.HostID == lobby.HostID
                               select l);

                if (isthere != null)
                {
                    join.Lobby = lobby.HostPlayer;
                    join.HostID = lobby.HostID;
                    db.SubmitChanges();
                    updatelobby(lobby.HostID);
                }

                returnplay = player;
                returnplay.HostID = lobby.HostID;
                returnplay.Lobby = lobby.HostPlayer;
                return returnplay;
            }

            catch (Exception)
            {

                throw;
            }
        }
        public DTO.Player Inloggen(string naam, string wachtwoord)
        {
            try
            {

                // List<DTO.Player> playerList = new List<DTO.Player>();

                DTO.Player player = new DTO.Player();

                // look for player
                //var usercontrol = from u in db.Players
                //                  where u.PlayerNaam == naam && u.Wachtwoord == wachtwoord
                //                  select new { u.PlayerNaam, u.Gewonnen, u.Verloren, u.Wachtwoord, u.PlayerId, u.Lobby, u.IsHost };

                var user = (from u in db.Players
                            where u.PlayerNaam == naam && u.Wachtwoord == wachtwoord
                            select u).First();

                player.PlayerId = user.PlayerId;
                player.PlayerNaam = user.PlayerNaam;
                player.Lobby = user.Lobby;

                if (user.Locatie.HasValue)
                    player.Locatie = user.Locatie.Value;

                if (user.IsHost.HasValue)
                    player.IsHost = user.IsHost.Value;

                if (user.HostID.HasValue)
                    player.HostID = user.HostID.Value;

                if (user.Gewonnen.HasValue)
                    player.Gewonnen = user.Gewonnen.Value;

                if (user.Verloren.HasValue)
                    player.Verloren = user.Verloren.Value;

                // add players attributes
                //foreach (var item in user)
                //{
                //    playerList.Add(new DTO.Player() { PlayerNaam = item.PlayerNaam, Wachtwoord = item.Wachtwoord, PlayerId = item.PlayerId, Lobby = item.Lobby, IsHost=item.IsHost.Value, Gewonnen=item.Gewonnen.Value, Verloren=item.Verloren.Value });
                //}
                return player;
            }

            catch (Exception)
            {

                throw;
            }
        }