예제 #1
0
        public Task <User> FindByIdAsync(string userId)
        {
            if (string.IsNullOrWhiteSpace(userId))
            {
                throw new ArgumentNullException("userId");
            }

            Guid parsedUserId = new Guid(userId);

            if (!Guid.TryParse(userId, out parsedUserId))
            {
                throw new ArgumentOutOfRangeException("userId", string.Format("'{0}' is not a valid GUID.", new { userId }));
            }

            Account account = _proxy.FindById(parsedUserId);
            User    user    = ModelAccountToIdentityUser(account);


            return(Task.FromResult <User>(user));
        }
예제 #2
0
        public HighscoresViewModel()
        {
            _highscoreProxy = new HighscoreServiceClient();
            _accountProxy   = new AccountServiceClient();
            _highscores     = new Dictionary <string, int>();

            foreach (var kvp in _highscoreProxy.GetHighscores())
            {
                _highscores.Add(_accountProxy.FindById(kvp.Key).Username, kvp.Value);
            }
        }
예제 #3
0
        private void OpenLobby(object parameter)
        {
            Guid            lobbyId         = (Guid)parameter;
            Lobby           lobbyToOpen     = _lobbyProxy.GetLobbyById(lobbyId);
            CustomPrincipal customPrincipal = Thread.CurrentPrincipal as CustomPrincipal;
            Guid            userId          = customPrincipal.Identity.Id;
            Account         account         = _accountProxy.FindById(userId);

            //TODO: Check if private and do whatever from there
            if (ContainsAccount(userId, lobbyId))
            {
                LobbyWindow _lobbyWindow = new LobbyWindow(lobbyToOpen, _dashboardWindow);

                _lobbyWindow.Show();
                Lobbies = _lobbyProxy.GetLobbies();
            }
            else
            {
                MessageBox.Show("You already joined a lobby", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }