public ActionResult Register(RegisterViewModel model) { if (!User.IsInRole("Admin")) { return(RedirectToAction("Login")); } if (!ModelState.IsValid) { return(View(model)); } if (model.Password == model.PasswordCheck) { var hasher = new PasswordHasher <Account>(); Account tempAccount = new Account(0, model.Username, model.Rockstars, model.IsAdmin, model.Password); string hashedPW = hasher.HashPassword(tempAccount, model.Password); tempAccount.Password = hashedPW; APIHelper.InitializeClient(); AccountOperations.Create(tempAccount); return(RedirectToAction("Index", "Home")); } ModelState.AddModelError(nameof(model.Username), "Passwords do not match"); return(View(model)); }
private void btn_transferToUser2_Click(object sender, EventArgs e) { AccountOperations op = new AccountOperations(); string cardNumber = tb_recCardNumber.Text; decimal moneyAmount = Convert.ToDecimal(tb_moneyAmount2.Text, CultureInfo.InvariantCulture); try { op.TransferMoneyToUserByCardNumber(client, accId, long.Parse(cardNumber), moneyAmount); MessageBox.Show("Средства успешно переведены"); DateTime today = DateTime.Now; DateTime todayDate = DateTime.Today; string transactionType = "Перевод средств со счета"; string time = today.ToString("HH:mm:ss"); // Записываем в архив OperationsRecorder.RecordAccountOperation ( userAccId, todayDate.ToString("dd/MM/yyyy"), time, transactionType, Convert.ToDecimal(tb_moneyAmount2.Text, CultureInfo.InvariantCulture) ); } catch (Exception exc) { MessageBox.Show(exc.Message); } }
public void MakeTransfer(decimal Amount) { var ops = new AccountOperations(); var response = ops.Transfer(_currentAccount, _targetAccount, Amount); if (response.Success) { Console.WriteLine(); Console.WriteLine("Transfered {0:c} to {1}'s account (#{2}) from {3}'s account (#{4})", response.TransferInfo.TransferAmount, response.TransferInfo.TargetAccountName, response.TransferInfo.TargetAccountNumber, response.TransferInfo.CurrentAccountName, response.TransferInfo.CurrentAccountNumber); Console.WriteLine("{0}'s New Balance: {1}", response.TransferInfo.CurrentAccountName, response.TransferInfo.NewBalanceCurrentAccount); Console.WriteLine("{0}'s New Balance: {1}", response.TransferInfo.TargetAccountName, response.TransferInfo.NewBalanceTargetAccount); Console.WriteLine("Press Enter to continue..."); Console.ReadLine(); } else { Console.WriteLine(); Console.WriteLine(response.Message); Console.WriteLine("Press Enter to continue..."); Console.ReadLine(); } }
private void btn_transferToUser1_Click_1(object sender, EventArgs e) { AccountOperations op = new AccountOperations(); decimal moneyAmount = Convert.ToDecimal(tb_moneyAmount1.Text, CultureInfo.InvariantCulture); string accountId = tb_recAccountId.Text; try { op.TransferMoneyToUserByAccId(client, accId, accountId, moneyAmount); MessageBox.Show("Средства успешно переведены"); DateTime today = DateTime.Now; DateTime todayDate = DateTime.Today; string transactionType = "Перевод средств со счета"; string time = today.ToString("HH:mm:ss"); // Записываем в архив OperationsRecorder.RecordAccountOperation ( userAccId, todayDate.ToString("dd/MM/yyyy"), time, transactionType, Convert.ToDecimal(tb_moneyAmount1.Text, CultureInfo.InvariantCulture) ); } catch (Exception exc) { MessageBox.Show("Данный банковский счет не зарегистрирован"); } }
private void btn_transferSomewhere_Click(object sender, EventArgs e) { AccountOperations op = new AccountOperations(); string paymentDest = tb_transferDestination.Text; decimal moneyAmount = Convert.ToDecimal(tb_moneyAmount3.Text, CultureInfo.InvariantCulture); try { op.TransferMoneySomeWhereFromAcc(client, accId, moneyAmount); MessageBox.Show("Средства успешно переведены"); DateTime today = DateTime.Now; DateTime todayDate = DateTime.Today; string transactionType = "Перевод средств со счета"; string time = today.ToString("HH:mm:ss"); // Записываем в архив OperationsRecorder.RecordAccountOperation ( userAccId, todayDate.ToString("dd/MM/yyyy"), time, transactionType, Convert.ToDecimal(tb_moneyAmount3.Text, CultureInfo.InvariantCulture) ); } catch (Exception exc) { MessageBox.Show("Ошибка сервиса. Пожалуйста, повторите позже"); } }
public ActionResult SecureAccount(UIAccount_S uim) { AjaxStatus status = new AjaxStatus(); using (var context = new DataContext()) { try { Account dbm = AccountOperations.TryRead(Account.EMPTY_ACCOUNT, context, uim.email); dbm = uim.UpdateModel(dbm); if (AccountOperations.TrySecure(Account.EMPTY_ACCOUNT, context, dbm, uim.PIN)) { SetLoginAccount(dbm); status.nextURL = "/Home"; } else { uim.ResetModel(dbm); status.SetError("Felaktig eller för gammal PIN-kod"); } context.SaveChanges(); } catch (Exception e) { base.HandleException("SecureAccount", e); status.SetError(e.Message); } } return(Json(status)); }
public Client() { // Load the requestor _requestor = new Requestor(); // Setup the operations AccountOperations = new AccountOperations(_requestor); MessageOperations = new MessageOperations(_requestor); }
public void MakeWithdrawal() { AccountOperations ops = new AccountOperations(); Account account = new Account() { AccountNumber = "123456", Balance = 1234.56m }; Assert.IsTrue(ops.MakeWithdrawal(account, 2000)); }
private void ProcessWithdrawal() { var ops = new AccountOperations(); var response = ops.MakeWithdrawal(Account, amount); if (!response.Success) { Console.WriteLine("Error occurred."); Console.WriteLine(response.Message); } }
private async Task <BankDataSheet> GetAccountData(string account, DateTime startDate, DateTime endDate) { this.sessionId = await this.LoginAndGetSessionId(); AccountOperations accountOperations = new AccountOperations(this.client, this.sessionId, this.sequence); XDocument document = await accountOperations.GetAccountData(account, startDate, endDate); this.oldDataManager.StoreData(document, account); return(this.xmlTransformer.TransformXml(document)); }
public async Task <IActionResult> Account() { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login")); } APIHelper.InitializeClient(); Account user = await AccountOperations.Get(User.Identity.Name); return(View(user)); }
public void ShouldUpdateBalanceForValidTransaction() { var account = new Account(); account.Balance = 100; MakePaymentRequest request = new MakePaymentRequest(); request.Amount = 50; request.DebtorAccountNumber = "12345679"; AccountOperations.DeductBalanceAndUpdateAccount("dataStore", account, request); Assert.Equal(account.Balance, 50); }
public async Task GetBalance() { var test = CreateHttpTest() .ExpectUriPath("accounts/balance") .ResponseBodyFromFile("account/account_balance.json"); var expected = test.ResponseBody <AccountBalanceInfo>(); var operations = new AccountOperations(test.HttpClient, BaseUri, ClientId, ClientSecret, ReloadlyEnvironment.Sandbox); var actual = await operations.GetBalanceAsync(); Verify(expected, actual); }
private void button7_Click(object sender, EventArgs e) { try { AccountOperations op = new AccountOperations(); op.TransferMoneyToUserByNumber(curClient, accId.Last <string>().ToString(), 79019101122, 5000); MessageBox.Show("ЧЕТКО!!!"); } catch (Exception ex) { MessageBox.Show("ПИЗДЕЦ!!!"); MessageBox.Show(ex.Message); } }
public AccountController( IUserService userService, ISettings settings, IWGOpenId wgOpenId, IDiscordOauth2 discordOauth2, IWarshipsApi warshipsApi, AccountOperations accounts) { _user = userService; _settings = settings; _wgOpenId = wgOpenId; _warshipsApi = warshipsApi; _discordOauth2 = discordOauth2; Accounts = accounts; }
public MakePaymentResult MakePayment(MakePaymentRequest request) { var dataStoreType = ConfigurationManager.AppSettings["DataStoreType"]; var account = DataStore.GetAccount(dataStoreType, request); var result = new MakePaymentResult(); result.Success = PaymentOperations.ExecutePayment(request.PaymentScheme, account, request); if (result.Success) { AccountOperations.DeductBalanceAndUpdateAccount(dataStoreType, account, request); } return(result); }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } //get use by username and only continue if it exists APIHelper.InitializeClient(); Account user = await AccountOperations.Get(model.Username); //check username if (user == null) { ModelState.AddModelError("", "Username or password is incorrect."); return(View(model)); } //check password var hasher = new PasswordHasher <Account>(); if (hasher.VerifyHashedPassword(user, user.Password, model.Password) == PasswordVerificationResult.Failed) { ModelState.AddModelError("", "Username or password is incorrect."); return(View(model)); } var claims = new List <Claim> { new Claim(ClaimTypes.Name, user.Name), new Claim(ClaimTypes.UserData, user.Points.ToString()) }; if (user.IsAdmin) { claims.Add(new Claim(ClaimTypes.Role, "Admin")); } var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var authProperties = new AuthenticationProperties(); await HttpContext.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties); return(RedirectToAction("Index", "Home")); }
static void Main(string[] args) { List <Account> accounts = new List <Account>(); AccountOperations accountService = new AccountOperations(); accountService.CreateAccount(new Account(111, "Ivan", "Ivanov", 100m, 5, AccountType.Base)); accountService.CreateAccount(new Account(112, "Petr", "Petrov", 1250m, 40, AccountType.Gold)); accountService.CreateAccount(new Account(113, "Sidor", "Sidorov", 10245m, 120, AccountType.Premium)); PrintAll(accountService.GetAllAccounts()); accountService.AddAmount(111, 500m); PrintAll(accountService.GetAllAccounts()); Console.ReadKey(); }
public ActionResult SignUp(AccountViewModel model) { if (!ModelState.IsValid) { return(View()); } else { AccountModel accountModel = new AccountModel(); accountModel.EmailId = model.EmailId; accountModel.Password = model.Password; accountModel.FullName = model.FullName; AccountOperations accountOperations = new AccountOperations(); accountOperations.SignUp(accountModel); } return(RedirectToAction("Login")); }
static void Main(string[] args) { //PrintHeading("Assignment - 1"); //FormatQuestion(); //Console.WriteLine($"1. Write a program in C# Sharp for a 2D array of size 3x3 and print the matrix"); //FormatSolution(); //Matrix.DisplayMatrix(); //FormatQuestion(); //Console.WriteLine($"2. Write an application to implement multiple inheritance and overriding using virtual method."); //FormatSolution(); //Rectangle rectangle = new Rectangle(5, 7, "Rec #1"); //Circle circle = new Circle(5, "Circle #1"); //// Print the area of the object. //Console.WriteLine($"Shape details : {rectangle}. Paint cost will be : INR {rectangle.GetCost(rectangle.Area)}."); //Console.WriteLine($"Shape details : {circle}."); //FormatQuestion(); //Console.WriteLine($"3. Application is maintaining a collection (List) of Integers as NumList. We need to print the numbers from NumList those are divisible by 3. Implement the functionality using:{Environment.NewLine} \t A.Delegates{Environment.NewLine}\t B.Lambda Expression."); //FormatSolution(); //CollectionDemo.PrintListByLambda(); //CollectionDemo.PrintListByDelegate(); ////Student E = new Student(); ////E.GetInfo(); ////Stud Stud = new Stud(); ////Stud.GetInfo(); //Console.WriteLine($"4.Extend the functionality of the System.String class with function IsEmail() that will check the user input."); //FormatSolution(); //Console.WriteLine(" Is Input string [[email protected]] is an Email? {0}", "*****@*****.**".IsEmail()); //PrintHeading("Assignment - 2"); //ShowPersonDetails(); AccountOperations.PerformOperation(); Console.ReadKey(); }
public ActionResult ResendPIN(string email) { AjaxStatus status = new AjaxStatus(); using (var context = new DataContext()) { try { Account dbm = AccountOperations.TryRead(Account.EMPTY_ACCOUNT, context, email); AccountOperations.TryResendPIN(Account.EMPTY_ACCOUNT, context, dbm); context.SaveChanges(); } catch (Exception e) { base.HandleException("ResendPIN", e); status.SetError(e.Message); } } return(Json(status)); }
public ActionResult Login(AccountViewModel model) { if (!ModelState.IsValid) { return(View()); } AccountModel accountModel = new AccountModel(); accountModel.EmailId = model.EmailId; accountModel.Password = model.Password; AccountOperations accountOperations = new AccountOperations(); if (accountOperations.Login(accountModel) == true) { FormsAuthentication.SetAuthCookie(model.EmailId, false); return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("", "Invalid Username and Password"); return(View()); }
private Account RetrieveAccountByNumber(string accountNumber) { var ops = new AccountOperations(); var response = ops.GetAccount(accountNumber); if (response.Success) { return(response.AccountInfo); } //Account account; else { Console.WriteLine("Error Occurred."); Console.WriteLine(response.Message); Console.WriteLine("Press enter to continue."); Console.ReadLine(); } return(null); }
private void btn_transferToUser2_Click(object sender, EventArgs e) { if (tb_moneyAmount2.Text == "" || tb_recCardNumber.Text == "") { MessageBox.Show("Заполните все поля"); return; } AccountOperations op = new AccountOperations(); decimal moneyAmount = Convert.ToDecimal(tb_moneyAmount2.Text, CultureInfo.InvariantCulture); string recieverCardId = tb_recCardNumber.Text; try { op.TransferMoneyFromCardToCard(client, cardId, long.Parse(recieverCardId), moneyAmount); MessageBox.Show("Средства успешно переведены"); cardRecordId = BankAccountManagement.GetUserCardId(cardId); DateTime today = DateTime.Now; DateTime todayDate = DateTime.Today; string transactionType = "Перевод средств с карты"; string time = today.ToString("HH:mm:ss"); // Записываем в архив OperationsRecorder.RecordCardOperation ( cardRecordId, todayDate.ToString("dd/MM/yyyy"), time, transactionType, Convert.ToDecimal(tb_moneyAmount2.Text, CultureInfo.InvariantCulture) ); } catch (Exception exc) { MessageBox.Show(exc.Message); } }
private void btn_transferSomewhere_Click(object sender, EventArgs e) { if (tb_moneyAmount3.Text == "" || tb_transferDestination.Text == "") { MessageBox.Show("Заполните все поля"); return; } AccountOperations op = new AccountOperations(); decimal moneyAmount = Convert.ToDecimal(tb_moneyAmount3.Text, CultureInfo.InvariantCulture); try { op.TransferMoneySomeWhereFromCard(client, cardId, moneyAmount); MessageBox.Show("Средства успешно переведены"); cardRecordId = BankAccountManagement.GetUserCardId(cardId); DateTime today = DateTime.Now; DateTime todayDate = DateTime.Today; string transactionType = "Перевод средств с карты"; string time = today.ToString("HH:mm:ss"); // Записываем в архив OperationsRecorder.RecordCardOperation ( cardRecordId, todayDate.ToString("dd/MM/yyyy"), time, transactionType, Convert.ToDecimal(tb_moneyAmount3.Text, CultureInfo.InvariantCulture) ); } catch (Exception exc) { MessageBox.Show("Такой банковской карты нет в базе данных"); } }
public void MakeDeposit(decimal Amount) { var ops = new AccountOperations(); var response = ops.Deposit(_currentAccount, Amount); if (response.Success) { Console.WriteLine(); Console.WriteLine("Depositted {0:c} to account {1}.", response.DepositInfo.DepositAmount, response.DepositInfo.AccountNumber); Console.WriteLine("New Balance: {0:c}", response.DepositInfo.NewBalance); Console.WriteLine("Press Enter to continue..."); Console.ReadLine(); } else { Console.WriteLine(); Console.WriteLine(response.Message); Console.WriteLine("Press Enter to continue..."); Console.ReadLine(); } }
public bool DisplayTargetAccountInfo(int AccountNumber) { var ops = new AccountOperations(); var response = ops.GetAccount(AccountNumber); if (response.Success) { _targetAccount = response.AccountInfo; Console.WriteLine("We will be transfering money to {0} {1} with Account Number {2} and a current balance of {3}.", _targetAccount.FirstName, _targetAccount.LastName, _targetAccount.AccountNumber, _targetAccount.Balance); Console.WriteLine("Press Enter to continue..."); Console.ReadLine(); return(true); } else { Console.WriteLine("Error Occurred!!"); Console.WriteLine("This account does not exist."); Console.WriteLine("Press Enter to continue..."); Console.ReadLine(); return(false); } }
public void DisplayAccountInformation(int AccountNumber) { var ops = new AccountOperations(); var response = ops.GetAccount(AccountNumber); if (response.Success) { _currentAccount = response.AccountInfo; PrintAccountInformation(response.AccountInfo); Console.ReadLine(); DisplayAccountMenu(); } else { Console.WriteLine("Error Occurred!!!"); Console.WriteLine(response.Message); Console.WriteLine("Press Enter to continue..."); Console.ReadLine(); } }
static void Main(string[] args) { int option = Authentication.Welcome(); if (option == 1) { Console.Clear(); var registration = Authentication.Registration(option); if (registration != null) { Console.Clear(); var login = Authentication.Login(registration); if (login == true) { Console.Clear(); var account = Dashboard.ShowDashboard(registration); //AllAccounts.Add(account); if (account != null) { Console.Clear(); var response = AccountOperations.UserAccountOperations(account); if (response != null) { Console.WriteLine("Back To Base"); //AccountOperations.UserAccountOperations(response); } } } } } }
public void InitUserObject() { transaction = new List <TransactionLogs>() { new TransactionLogs() { Amount = 200, IsIncome = true, UserId = 1 }, new TransactionLogs() { Amount = 100, IsIncome = false, UserId = 2 } }.AsQueryable(); account = new List <Account>() { new Account() { NRB = 909392000000018909, Ammount = 100, AccountId = 1, UserId = 1 }, new Account() { NRB = 890989000000029834, Ammount = 10, AccountId = 1, UserId = 2 } }.AsQueryable(); users = new List <User>() { new User() { Login = "******", Password = "******", UserId = 1 }, new User() { Login = "******", Password = "******", UserId = 2 } }.AsQueryable(); mockSetUser = Substitute.For <DbSet <User>, IQueryable <User> >(); ((IQueryable <User>)mockSetUser).Provider.Returns(users.Provider); ((IQueryable <User>)mockSetUser).Expression.Returns(users.Expression); ((IQueryable <User>)mockSetUser).ElementType.Returns(users.ElementType); ((IQueryable <User>)mockSetUser).GetEnumerator().Returns(users.GetEnumerator()); mockSetAccount = Substitute.For <DbSet <Account>, IQueryable <Account> >(); ((IQueryable <Account>)mockSetAccount).Provider.Returns(account.Provider); ((IQueryable <Account>)mockSetAccount).Expression.Returns(account.Expression); ((IQueryable <Account>)mockSetAccount).ElementType.Returns(account.ElementType); ((IQueryable <Account>)mockSetAccount).GetEnumerator().Returns(account.GetEnumerator()); mockSetTransaction = Substitute.For <DbSet <TransactionLogs>, IQueryable <TransactionLogs> >(); ((IQueryable <TransactionLogs>)mockSetTransaction).Provider.Returns(transaction.Provider); ((IQueryable <TransactionLogs>)mockSetTransaction).Expression.Returns(transaction.Expression); ((IQueryable <TransactionLogs>)mockSetTransaction).ElementType.Returns(transaction.ElementType); db = Substitute.For <IEFDbContext>(); db.accounts.Returns(mockSetAccount); db.transactionLogs.Returns(mockSetTransaction); db.users.Returns(mockSetUser); accountOperations = new AccountOperations(db); }