Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
Ejemplo n.º 1
0
        public static void CheckUserData(string userName, string password, string serverUrl, AuthentificateUserCallback callback)
        {
            _authCallback = callback;
            Server server = null;
            _authUser = new User();
            using (var serverRepository = new ServerRepository())
            {
                server = serverRepository.TryGetServerByAddress(serverUrl);

            }
            if (server != null)
            {

                User user = null;
                using (var userRepository = new UserRepository())
                {
                    user = userRepository.TryGetUserByNamePasswordAndServerID(userName, password, server.ID);
                }
                if (user != null)
                {
                    _authUser = user;
                    AuthentificateUserCallback(AuthentificationCode.LoginSuccessed);
                    return;
                }

                _authUser.ServerID = server.ID;
            }
            else
            {
                server = new Server
                {
                    Address = serverUrl,
                };
                _authUser.Server = server;
            }

            _authUser.Name = userName;
            _authUser.Password = password;
            if (InternetChecker.IsInernetActive)
                new AuthentitficationDataService().AuthentificateUser(_authUser.Name, _authUser.Password, serverUrl, CheckUserDataCallback);
            else
                InvokeCallbackWithAuthCodeParameter(AuthentificationCode.NoInternetConnection);
        }
Ejemplo n.º 2
0
        public  void TestInitialize()
        {
            if (Membership.CurrentUser == null)
            {
                UserRepository repository = new UserRepository();
                User user = new User();
                user = repository.TryGetCurrentUser();
                if (user == null)
                {
                    user = new User();
                    user.Name = LoginViewModelTest.LOGIN;
                    user.Password = LoginViewModelTest.PASSWORD;
                    Server server = new Server();
                    server.Address = LoginViewModelTest.SERVER_PATH;
                    user.ID = 0;
                    user.Server = server;
                    user.IsCurrent = true;
                    repository.AddNewUser(user);
                }

                Membership.CheckUserData(user.Name, user.Password, user.Server.Address, this.OnUserAuthenticated);
            }
        }
 partial void DeleteServer(Server instance);
 partial void UpdateServer(Server instance);
 partial void InsertServer(Server instance);