public ActionResult Login(string userId, string password) { AccountInfo info = new AccountInfo(); if (ModelState.IsValid) { info.userid = userId; info.password = password; try { using (svcClient = new AccountServiceClient()) { if (svcClient.Authenticate(info)) { Session["IsAuthenticated"] = true; Session["User"] = userId; return View("LoggedIn"); } } } catch (FaultException<AccountServiceFault> ex) { HandleErrorInfo errorInfo = new HandleErrorInfo(ex, "Home", "Login"); return View("Error", errorInfo); } } ViewBag.LoginFailed = "Oops... user credential is not matched, please try again!"; return View(); }
private static void TrySendEmail() { using (AccountServiceClient accountClient = new AccountServiceClient()) { object obj = accountClient.SendTestEmail("*****@*****.**"); } }
public async void when_registering_2_account_with_same_twitterId() { var twitterId = Guid.NewGuid(); var sut = new AccountServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); var newAccount = new RegisterAccount { AccountId = Guid.NewGuid(), Phone = "5145551234", Country = new CountryISOCode("CA"), Email = GetTempEmail(), Name = "First Name Test", TwitterId = twitterId.ToString() }; await sut.RegisterAccount(newAccount); var newAccount2 = new RegisterAccount { AccountId = Guid.NewGuid(), Phone = "5145551234", Country = new CountryISOCode("CA"), Email = GetTempEmail(), Name = "First Name Test", TwitterId = twitterId.ToString() }; Assert.Throws <WebServiceException>(async() => await sut.RegisterAccount(newAccount2), "CreateAccount_AccountAlreadyExist"); }
public ActionResult Register(string userId, string password, string firstName, string lastName) { AccountInfo info = new AccountInfo(); if (ModelState.IsValid) { info.userid = userId; info.password = password; info.firstname = firstName; info.lastname = lastName; try { using (svcClient = new AccountServiceClient()) { if (svcClient.CreateAccount(info)) { return(View("Index")); } } } catch (FaultException <AccountServiceFault> ex) { HandleErrorInfo errorInfo = new HandleErrorInfo(ex, "Home", "Register"); return(View("Error", errorInfo)); } } ViewBag.RegistionFailed = String.Format("Oops... user id: {0} already exists, please choose another one!", userId); return(View()); }
public ActionResult Login(string userId, string password) { AccountInfo info = new AccountInfo(); if (ModelState.IsValid) { info.userid = userId; info.password = password; try { using (svcClient = new AccountServiceClient()) { if (svcClient.Authenticate(info)) { Session["IsAuthenticated"] = true; Session["User"] = userId; return(View("LoggedIn")); } } } catch (FaultException <AccountServiceFault> ex) { HandleErrorInfo errorInfo = new HandleErrorInfo(ex, "Home", "Login"); return(View("Error", errorInfo)); } } ViewBag.LoginFailed = "Oops... user credential is not matched, please try again!"; return(View()); }
public async void UpdateBookingSettingsAccountTest() { var sut = new AccountServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); var initialAccount = await sut.GetMyAccount(); var settings = new BookingSettingsRequest { ChargeTypeId = ChargeTypes.CardOnFile.Id, Name = "toto", NumberOfTaxi = 6, Passengers = 8, Phone = "5141234567", Country = new CountryISOCode("CA"), ProviderId = 13, VehicleTypeId = 1, DefaultTipPercent = 15, Email = initialAccount.Email }; await sut.UpdateBookingSettings(settings); var updatedAccount = await sut.GetMyAccount(); Assert.AreEqual(settings.ChargeTypeId, updatedAccount.Settings.ChargeTypeId); Assert.AreEqual(settings.Name, updatedAccount.Settings.Name); Assert.AreEqual(settings.NumberOfTaxi, updatedAccount.Settings.NumberOfTaxi); Assert.AreEqual(settings.Passengers, updatedAccount.Settings.Passengers); Assert.AreEqual(settings.Phone, updatedAccount.Settings.Phone); Assert.AreEqual(settings.ProviderId, updatedAccount.Settings.ProviderId); Assert.AreEqual(settings.VehicleTypeId, updatedAccount.Settings.VehicleTypeId); Assert.AreEqual(settings.DefaultTipPercent, updatedAccount.DefaultTipPercent); Assert.AreEqual(settings.AccountNumber, updatedAccount.Settings.AccountNumber); Assert.AreEqual(settings.CustomerNumber, updatedAccount.Settings.CustomerNumber); }
private void UpdateAccountBalance() { try { _indTriggerAccountBalance.OnGet(); var start = DateTime.Now; if (string.IsNullOrEmpty(FromAccount)) { _accountBalance = 0.0m; } else { using (AccountServiceClient service = new AccountServiceClient()) { _accountBalance = service.GetAccountBalance(FromAccount); } } var end = DateTime.Now; LastError = (end - start).ToString(); } catch (Exception ex) { while (ex.InnerException != null) { ex = ex.InnerException; } LastError = ex.Message; _accountBalance = 0.0m; } }
public async void RemoveCreditCard() { var client = GetFakePaymentClient(); var sut = new AccountServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null, client); const string creditCardComapny = "visa"; const string nameOnCard = "Bob"; var creditCardId = Guid.NewGuid(); const string last4Digits = "4025"; const string expirationMonth = "5"; const string expirationYear = "2020"; const string label = "Personal"; var cc = new TestCreditCards(TestCreditCards.TestCreditCardSetting.Cmt); var tokenResponse = await client.Tokenize(cc.Discover.Number, cc.Discover.NameOnCard, cc.Discover.ExpirationDate, cc.Discover.AvcCvvCvv2.ToString(), null, cc.Discover.ZipCode, TestAccount); await sut.AddCreditCard(new CreditCardRequest { CreditCardCompany = creditCardComapny, NameOnCard = nameOnCard, CreditCardId = creditCardId, Last4Digits = last4Digits, ExpirationMonth = expirationMonth, ExpirationYear = expirationYear, Token = tokenResponse.CardOnFileToken, Label = label }); await sut.RemoveCreditCard(creditCardId, tokenResponse.CardOnFileToken); var creditCards = await sut.GetCreditCards(); Assert.IsEmpty(creditCards); }
public async void when_updating_twitter_account_password() { var sut = new AccountServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); const string password = "******"; var accountId = Guid.NewGuid(); var twitterId = Guid.NewGuid(); var newAccount = new RegisterAccount { AccountId = Guid.NewGuid(), Phone = "5145551234", Country = new CountryISOCode("CA"), Email = GetTempEmail(), Name = "First Name Test", TwitterId = twitterId.ToString() }; await sut.RegisterAccount(newAccount); await new AuthServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null).AuthenticateTwitter(newAccount.TwitterId); var request = new UpdatePassword { AccountId = accountId, CurrentPassword = password, NewPassword = "******" }; Assert.Throws <WebServiceException>(async() => await sut.UpdatePassword(request)); }
public async void AddAddress() { var sut = new AccountServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); var addressId = Guid.NewGuid(); await sut.AddFavoriteAddress(new SaveAddress { Id = addressId, Address = new Address { FriendlyName = "Chez François Cuvelier", Apartment = "3939", FullAddress = "1234 rue Saint-Hubert", RingCode = "3131", BuildingName = "Hôtel de Ville", Latitude = 45.515065, Longitude = -73.558064 } }); var addresses = await sut.GetFavoriteAddresses(); Assert.AreEqual(1, addresses.Count(x => x.Id == addressId)); var address = addresses.Single(x => x.Id == addressId); Assert.AreEqual("3939", address.Apartment); Assert.AreEqual("3131", address.RingCode); Assert.AreEqual("1234 rue Saint-Hubert", address.FullAddress); Assert.AreEqual("Hôtel de Ville", address.BuildingName); Assert.AreEqual(45.515065, address.Latitude); Assert.AreEqual(-73.558064, address.Longitude); }
public async void UpdateAddress() { var sut = new AccountServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); await sut.UpdateFavoriteAddress(new SaveAddress { Id = _knownAddressId, Address = new Address { FriendlyName = "Chez François Cuvelier", Apartment = "3939", FullAddress = "1234 rue Saint-Hubert", RingCode = "3131", BuildingName = "Le Manoir", Latitude = 12, Longitude = 34 } }); var addresses = await sut.GetFavoriteAddresses(); var address = addresses.Single(x => x.Id == _knownAddressId); Assert.AreEqual("Chez François Cuvelier", address.FriendlyName); Assert.AreEqual("3939", address.Apartment); Assert.AreEqual("1234 rue Saint-Hubert", address.FullAddress); Assert.AreEqual("3131", address.RingCode); Assert.AreEqual("Le Manoir", address.BuildingName); Assert.AreEqual(12, address.Latitude); Assert.AreEqual(34, address.Longitude); }
public void CreateUser_Test() { var client = new AccountServiceClient(); client.CreateUser(new User { Username = "******", Password = "******" }); }
public void CreateService_Test() { var client = new AccountServiceClient(); client.CreateService(new Service { NameService = "AO-service-report" }); }
public static void execute() { AuthHeader authHeader = new AuthHeader(); HeaderUtil.loadHeader(authHeader); AccountServiceClient client = new AccountServiceClient("AccountService", "https://api.baidu.com/sem/nms/v2/AccountService"); AccountInfoType account = getAccountInfo(client, authHeader); }
public void when_resetting_password_with_unknown_email_address() { var sut = new AccountServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); var exception = Assert.Throws <WebServiceException>(async() => await sut.ResetPassword("*****@*****.**")); Assert.AreEqual(500, exception.StatusCode); }
/// <summary> /// 加载GrpcService /// </summary> private void initialGrpcService() { //加载GrpcBase this.accountService = new AccountServiceClient( new VersionTask.VersionTaskClient(GrpcBase.Channel), new AccountTask.AccountTaskClient(GrpcBase.Channel), Debug ); }
public void GetService_Test() { var client = new AccountServiceClient(); var user = client.CreateService(new Service { NameService = "AO-service-report" }); client.GetService(user.Id); }
public CurrentBalanceViewModel(IEventAggregator eventAggregator ) { _eventAggregator = eventAggregator; _eventAggregator.GetEvent<AccountBalanceChangedEvent>().Subscribe(OnAccountBalanceChanged, ThreadOption.UIThread); _proxy = new AccountServiceClient(); _proxy.CheckBalanceCompleted += OnCheckBalanceCompleted; _proxy.CheckBalanceAsync("001-012345"); }
public async void GetAddressList() { var sut = new AccountServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); var addresses = await sut.GetFavoriteAddresses(); var knownAddress = addresses.SingleOrDefault(x => x.Id == _knownAddressId); Assert.IsNotNull(knownAddress); }
public CurrentBalanceViewModel(IEventAggregator eventAggregator) { _eventAggregator = eventAggregator; _eventAggregator.GetEvent <AccountBalanceChangedEvent>().Subscribe(OnAccountBalanceChanged, ThreadOption.UIThread); _proxy = new AccountServiceClient(); _proxy.CheckBalanceCompleted += OnCheckBalanceCompleted; _proxy.CheckBalanceAsync("001-012345"); }
public async void RemoveAddress() { var sut = new AccountServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); await sut.RemoveFavoriteAddress(_knownAddressId); var addresses = await sut.GetFavoriteAddresses(); Assert.IsEmpty(addresses.Where(x => x.Id == _knownAddressId)); }
public LoginViewModel() { _accountProxy = new AccountServiceClient(); //Mediator.Subscribe("GoTo2Screen", OnGo2Screen); //Mediator.Subscribe("GoToLobbies", OnGoToLobbies); //Mediator.Subscribe("GoToProfile", OnGoToProfile); }
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); }
public WithdrawalViewModel(IEventAggregator eventAggregator) { _eventAggregator = eventAggregator; WithdrawCommand = new DelegateCommand<object>(ExecuteWithdrawCommand); _proxy = new AccountServiceClient(); _proxy.WithdrawCompleted += OnWithdrawCompleted; }
public static AccountInfoType getAccountInfo(AccountServiceClient client, AuthHeader authHeader) { AccountInfoType response = null; ResHeader resHeader = client.getAccountInfo(authHeader, out response); Console.WriteLine("AccountService.getAccountInfo(): "); ObjectDumper.WriteResponse(resHeader, response); return(response); }
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); } }
public WithdrawalViewModel(IEventAggregator eventAggregator) { _eventAggregator = eventAggregator; WithdrawCommand = new DelegateCommand <object>(ExecuteWithdrawCommand); _proxy = new AccountServiceClient(); _proxy.WithdrawCompleted += OnWithdrawCompleted; }
private void btnCreateAccount_Click(object sender, EventArgs e) { var acctService = new AccountServiceClient(); var acct = new Account(); acct.FirstName = txtFirstName.Text; acct.LastName = txtLastName.Text; acct.UserName = txtUserName.Text; acct.Password = txtPassword.Text; lblCreateAccMessage.Text = acctService.CreateAccount(acct); }
// ReSharper restore NotAccessedField.Local /// <summary> /// /// </summary> /// <param name="tracer"></param> /// <param name="accountServiceClient"></param> /// <param name="todoServiceClient"></param> /// <param name="tobuyServiceClient"></param> public HelloController(ITracer tracer, AccountServiceClient accountServiceClient, ToDoServiceClient todoServiceClient, ToBuyServiceClient tobuyServiceClient ) { _tracer = tracer; _accountServiceClient = accountServiceClient; _todoServiceClient = todoServiceClient; _tobuyServiceClient = tobuyServiceClient; _rnd = new Random(); }
public async void when_resetting_account_password() { var sut = new AccountServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); var newAccount = await sut.CreateTestAccount(); await new AuthServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null).Authenticate(newAccount.Email, TestAccountPassword); await sut.ResetPassword(newAccount.Email); Assert.Throws <WebServiceException>(async() => await sut.GetMyAccount()); }
public async void UpdateCreditCard() { var client = GetFakePaymentClient(); var sut = new AccountServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null, client); var creditCardId = Guid.NewGuid(); const string last4Digits = "4025"; const string label = "Personal"; var cc = new TestCreditCards(TestCreditCards.TestCreditCardSetting.Cmt); var tokenResponse = await client.Tokenize(cc.Discover.Number, cc.Discover.NameOnCard, cc.Discover.ExpirationDate, cc.Discover.AvcCvvCvv2.ToString(), null, cc.Discover.ZipCode, TestAccount); await sut.AddCreditCard(new CreditCardRequest { CreditCardCompany = "Discover", NameOnCard = "Bob", CreditCardId = creditCardId, Last4Digits = last4Digits, ExpirationMonth = cc.Discover.ExpirationDate.Month.ToString(), ExpirationYear = cc.Discover.ExpirationDate.Year.ToString(), Token = tokenResponse.CardOnFileToken, Label = label }); var tokenResponse2 = await client.Tokenize(cc.AmericanExpress.Number, cc.AmericanExpress.NameOnCard, cc.AmericanExpress.ExpirationDate, cc.AmericanExpress.AvcCvvCvv2.ToString(), null, cc.AmericanExpress.ZipCode, TestAccount); await sut.UpdateCreditCard(new CreditCardRequest { CreditCardCompany = "AmericanExpress", NameOnCard = "Bob2", CreditCardId = creditCardId, Last4Digits = "1234", ExpirationMonth = cc.AmericanExpress.ExpirationDate.Month.ToString(), ExpirationYear = cc.AmericanExpress.ExpirationDate.Year.ToString(), Token = tokenResponse2.CardOnFileToken, Label = "Business" }); var creditCards = await AccountService.GetCreditCards(); var creditcard = creditCards.First(x => x.CreditCardId == creditCardId); Assert.NotNull(creditcard); Assert.AreEqual(_creditCardTestAccount.Id, creditcard.AccountId); Assert.AreEqual("AmericanExpress", creditcard.CreditCardCompany); Assert.AreEqual(creditCardId, creditcard.CreditCardId); Assert.AreEqual("1234", creditcard.Last4Digits); Assert.AreEqual(tokenResponse2.CardOnFileToken, creditcard.Token); Assert.AreEqual("Business", creditcard.Label.ToString()); }
static void Main(string[] args) { AccountServiceClient _client = new AccountServiceClient(); try { _client.MonthlyFee(); Console.WriteLine("Monthly fee was collected successfully:)"); } catch (FaultException ex) { Console.WriteLine(ex.Message); Console.ReadKey(); } }
public async void when_updating_account_password() { var sut = new AccountServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null); var account = await CreateAndAuthenticateTestAccount(); await sut.UpdatePassword(new UpdatePassword { AccountId = account.Id, CurrentPassword = TestAccountPassword, NewPassword = "******" }); Assert.DoesNotThrow(() => new AuthServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null).Authenticate(account.Email, "p@55w0rddddddddd")); }
private void ThreadProc() { Random random = new Random(); while (!_interrupt.WaitOne(100)) { try { int fromIndex = random.Next(_accounts.Length); int toIndex = (fromIndex + random.Next(_accounts.Length - 1) + 1) % _accounts.Length; string fromAccount = _accounts[fromIndex]; string toAccount = _accounts[toIndex]; using (AccountServiceClient service = new AccountServiceClient()) { service.Transfer(fromAccount, toAccount, 0.01m); } } catch (Exception ex) { } } }
public Logon() { _client = new AccountServiceClient(new System.ServiceModel.NetTcpBinding(), new System.ServiceModel.EndpointAddress("net.tcp://c0040597.itcs.hp.com:9002/AccountService")); }
public ActionResult Register(string userId, string password, string firstName, string lastName) { AccountInfo info = new AccountInfo (); if (ModelState.IsValid) { info.userid = userId; info.password = password; info.firstname = firstName; info.lastname = lastName; try { using (svcClient = new AccountServiceClient()) { if (svcClient.CreateAccount(info)) { return View("Index"); } } } catch (FaultException<AccountServiceFault> ex) { HandleErrorInfo errorInfo = new HandleErrorInfo(ex, "Home", "Register"); return View("Error", errorInfo); } } ViewBag.RegistionFailed = String.Format("Oops... user id: {0} already exists, please choose another one!", userId); return View(); }
private void UpdateAccountBalance() { try { _indTriggerAccountBalance.OnGet(); var start = DateTime.Now; if (string.IsNullOrEmpty(FromAccount)) _accountBalance = 0.0m; else { using (AccountServiceClient service = new AccountServiceClient()) { _accountBalance = service.GetAccountBalance(FromAccount); } } var end = DateTime.Now; LastError = (end-start).ToString(); } catch (Exception ex) { while (ex.InnerException != null) ex = ex.InnerException; LastError = ex.Message; _accountBalance = 0.0m; } }
public void Transfer() { try { using (AccountServiceClient service = new AccountServiceClient()) { service.Transfer(FromAccount, ToAccount, TransferAmount); } ToAccount = string.Empty; TransferAmount = 0.0m; LastError = string.Empty; Refresh(); } catch (Exception ex) { while (ex.InnerException != null) ex = ex.InnerException; LastError = ex.Message; } }