Ejemplo n.º 1
0
        public bool Login(string username, string password)
        {
            //custom authentication
            AccountServiceClient client = null;


            try
            {
                client = new AccountServiceClient();
                bool authenticated = client.LoginUser(username, password);

                if (authenticated)
                {
                    Account accountCriteria = new Account();
                    accountCriteria.AccountUsername = username;
                    accountCriteria.AccountPassword = password;

                    _view.Accounts        = client.AccountRetrieveByCriteria(accountCriteria).ToList();
                    _view.TitleForDisplay = "Login Successful";
                }
                else
                {
                    _view.Accounts        = null;
                    _view.TitleForDisplay = "Sorry, username and/or password are not correct";
                    return(false);
                }
            }
            catch (TimeoutException te)
            {
                _log.Fatal(te);
            }
            catch (FaultException fe)
            {
                _log.Fatal(fe);
            }
            catch (CommunicationException ce)
            {
                _log.Fatal(ce);
            }

            catch (Exception ex)
            {
                _log.Fatal(ex);
            }

            finally
            {
                if (client != null)
                {
                    client.CloseProxy();
                }
            }

            return(true);
        }