public List <PayeeViewModel> GetCustomerPayees() { //Get the curent user UserManager <AppUser> userManager = new UserManager <AppUser>(new UserStore <AppUser>(db)); var user = userManager.FindById(User.Identity.GetUserId()); List <PayeeViewModel> customerPayees = new List <PayeeViewModel>(); var query = from p in db.Payees select p; List <Payee> qList = query.ToList(); foreach (Payee p in qList) { if (user.Payees.Contains(p)) { PayeeViewModel payee = new PayeeViewModel(); payee.PayeeName = p.Name; payee.PayeeID = p.PayeeID; payee.Type = p.PayeeType; customerPayees.Add(payee); } } return(customerPayees); }
public async Task <IActionResult> Put(int id, [FromBody] PayeeViewModel model) { model = await service.Update(id, model); if (model == null) { return(BadRequest()); } return(Ok(model)); }
public async Task <IActionResult> Post([FromBody] PayeeViewModel value) { value = await service.Create(value); if (value == null) { return(BadRequest()); } return(CreatedAtAction("Get", new { id = value.Id }, value)); }
public void Payee() { var payeeViewModel = new PayeeViewModel(); TestUtilities.AssertPropertyChangedEvent( this.viewModel, () => this.viewModel.Payee = payeeViewModel, nameof(this.viewModel.Payee)); Assert.Same(payeeViewModel, this.viewModel.Payee); }
public ActionResult Transfer(int id) { var userId = User.Identity.GetUserId(); var user = Request.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(userId); PayeeViewModel payeeViewModel = new PayeeViewModel() { PayeeAccountNumber = id, SenderAccountNumber = user.AccountNumber }; return(View(payeeViewModel)); }
// GET: Payee/Details/5 public ActionResult Details(int id) { var payee = repository.GetAll().FirstOrDefault(p => p.Id == id); var model = new PayeeViewModel { Id = payee.Id, Name = payee.Name, Keywords = payee.Keywords.Select(k => k.Value).ToList() }; return(View(model)); }
public ActionResult Create(PayeeViewModel model) { try { repository.Add(new Payee { Name = model.Name }); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public List <PayeeViewModel> GetPayees() { List <PayeeViewModel> allPayees = new List <PayeeViewModel>(); List <PayeeViewModel> customerPayees = GetCustomerPayees(); UserManager <AppUser> userManager = new UserManager <AppUser>(new UserStore <AppUser>(db)); var user = userManager.FindById(User.Identity.GetUserId()); foreach (Payee p in db.Payees) { if (user.Payees.Contains(p)) { } else { PayeeViewModel payee = new PayeeViewModel(); payee.PayeeName = p.Name; payee.PayeeID = p.PayeeID; payee.Type = p.PayeeType; allPayees.Add(payee); } } return(allPayees); }
public ActionResult PayBillsPage(PayeeViewModel Pay) { // get the customer AppUser Customer = db.Users.Find(Pay.UserCustomerProfile.Id); if (Customer == null) { return(RedirectToAction("Portal", "Home")); } // create a new transaction list for the trade List <BankingTransaction> PayeeTrans = new List <BankingTransaction>(); Checking CustomerChecking = db.CheckingAccount.Find(Pay.CheckingID); Saving CustomerSaving = db.SavingsAccount.Find(Pay.SavingID); if (CustomerChecking == null && CustomerSaving == null) { return(RedirectToAction("Portal", "Home")); } if (CustomerChecking != null) { if (CustomerChecking.Balance >= 0) { List <Checking> CheckingList = new List <Checking>(); CheckingList.Add(CustomerChecking); if (CustomerChecking.Balance - Pay.PayeeTransaction.Amount >= -50) { if (CustomerChecking.Balance - Pay.PayeeTransaction.Amount < 0 && CustomerChecking.Balance - Pay.PayeeTransaction.Amount >= -50) { BankingTransaction OverDrawn = new BankingTransaction { Amount = 30, BankingTransactionType = BankingTranactionType.Fee, TransactionDate = Pay.PayeeTransaction.TransactionDate, CheckingAccount = CheckingList, ApprovalStatus = ApprovedorNeedsApproval.Approved, TransactionDispute = DisputeStatus.NotDisputed, Description = "Over draw" }; CustomerChecking.Overdrawn = true; PayeeTrans.Add(OverDrawn); db.BankingTransaction.Add(OverDrawn); db.SaveChanges(); // Send the email String Body = CustomerChecking.Name.ToString() + " : has been overdrawn and you have been charged a $30 fee. Your current account balance is $" + CustomerChecking.Balance.ToString(); LonghornBank.Utility.Email.PasswordEmail(Customer.Email, "Overdrawn Account", Body); } BankingTransaction CheckingWithdrawl = new BankingTransaction { Amount = Pay.PayeeTransaction.Amount, BankingTransactionType = BankingTranactionType.BillPayment, TransactionDate = Pay.PayeeTransaction.TransactionDate, CheckingAccount = CheckingList, Description = Pay.PayeeTransaction.Description, ApprovalStatus = ApprovedorNeedsApproval.Approved, TransactionDispute = DisputeStatus.NotDisputed }; db.CheckingAccount.Find(CustomerChecking.CheckingID).Balance -= Pay.PayeeTransaction.Amount; db.BankingTransaction.Add(CheckingWithdrawl); db.SaveChanges(); } else { return(View("WithDrawalError")); } } else { return(View("BalanceError")); } } if (CustomerSaving != null) { if (CustomerSaving.Balance >= 0) { List <Saving> SavingList = new List <Saving>(); SavingList.Add(CustomerSaving); if (CustomerSaving.Balance - Pay.PayeeTransaction.Amount >= -50) { if (CustomerSaving.Balance - Pay.PayeeTransaction.Amount < 0 && CustomerSaving.Balance - Pay.PayeeTransaction.Amount >= -50) { BankingTransaction OverDrawn = new BankingTransaction { Amount = 30, BankingTransactionType = BankingTranactionType.Fee, TransactionDate = Pay.PayeeTransaction.TransactionDate, SavingsAccount = SavingList, TransactionDispute = DisputeStatus.NotDisputed, ApprovalStatus = ApprovedorNeedsApproval.Approved, Description = "Over draw" }; CustomerSaving.Overdrawn = true; PayeeTrans.Add(OverDrawn); db.BankingTransaction.Add(OverDrawn); db.SaveChanges(); // Send the email String Body = CustomerSaving.Name.ToString() + " : has been overdrawn and you have been charged a $30 fee. Your current account balance is $" + CustomerSaving.Balance.ToString(); LonghornBank.Utility.Email.PasswordEmail(Customer.Email, "Overdrawn Account", Body); } BankingTransaction CheckingWithdrawl = new BankingTransaction { Amount = Pay.PayeeTransaction.Amount, BankingTransactionType = BankingTranactionType.BillPayment, TransactionDate = Pay.PayeeTransaction.TransactionDate, SavingsAccount = SavingList, Description = "Payment of bill", ApprovalStatus = ApprovedorNeedsApproval.Approved, TransactionDispute = DisputeStatus.NotDisputed }; db.SavingsAccount.Find(CustomerSaving.SavingID).Balance -= Pay.PayeeTransaction.Amount; db.BankingTransaction.Add(CheckingWithdrawl); db.SaveChanges(); } else { return(View("WithDrawalError")); } } else { return(View("BalanceError")); } } return(View("SuccessfulPayee")); }
public ActionResult PayBillsPage() { // Query the Database for the logged in user var CustomerQuery = from c in db.Users where c.UserName == User.Identity.Name select c; // Get the Customer AppUser customer = CustomerQuery.FirstOrDefault(); if (customer.ActiveStatus == false) { return(View("Frozen")); } if (customer == null) { return(HttpNotFound()); } // Populate a list of Checking Accounts var CheckingQuery = from ca in db.CheckingAccount where ca.Customer.Id == customer.Id select ca; // Create a list of accounts of execute List <Checking> AllCheckingAccounts = CheckingQuery.ToList(); Checking SelectNone = new Checking() { CheckingID = 0, AccountNumber = "1000000000000", Balance = 0, Name = "None" }; SelectNone.AccountDisplay = SelectNone.Name + " " + SelectNone.Balance; AllCheckingAccounts.Add(SelectNone); foreach (var account in AllCheckingAccounts) { account.AccountNumber = "XXXXXX" + account.AccountNumber.Substring(6); account.AccountDisplay = account.Name + " | " + account.Balance; } // Populate a list of Savings Accounts var SavingsQuery = from sa in db.SavingsAccount where sa.Customer.Id == customer.Id select sa; // Create a list of accounts of execute List <Saving> AllSavingsAccounts = SavingsQuery.ToList(); Saving SelectNoneSavings = new Saving() { SavingID = 0, AccountNumber = "1000000000000", Balance = 0, Name = "None" }; SelectNoneSavings.AccountDisplay = SelectNoneSavings.Name + " " + SelectNoneSavings.Balance; AllSavingsAccounts.Add(SelectNoneSavings); foreach (var account in AllSavingsAccounts) { account.AccountNumber = "XXXXXX" + account.AccountNumber.Substring(6); account.AccountDisplay = account.Name + " | " + account.Balance; } PayeeViewModel PayeeCustomerInfo = new PayeeViewModel { UserCustomerProfile = customer, PayeeAccount = customer.PayeeAccounts, CheckingAccounts = new SelectList(AllCheckingAccounts, "CheckingID", "AccountDisplay"), SavingsAccounts = new SelectList(AllSavingsAccounts, "SavingID", "AccountDisplay") }; return(View(PayeeCustomerInfo)); }