public ActionResult AddAccount(AddAccountForm form) { if (!IsConnected) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { var customer = Session[Utils.SessionAddAccountCustomer] as Customer; if (customer == null) { TempData["error"] = "client inconnu"; return(RedirectToAction("Index")); } validCreateAccount(form); if (ModelState.IsValid) { customer = customerRepo.GetCustomerByID(customer.ID); customer.Accounts.Add(new Account { BIC = form.BIC, IBAN = form.IBAN, Owner = customer, Solde = 0d }); customerRepo.Save(); TempData["notice"] = "Compte ajouté"; Session[Utils.SessionAddAccountCustomer] = null; return(RedirectToAction("Index")); } ViewBag.customer = customer; } return(View()); }
private void on_load(object sender, EventArgs e) { toolBar.Renderer = new CustomRenderToolStrip(); configForm = new ConfigForm(); configForm.configSaved += ConfigForm_configSaved; addAccountForm = new AddAccountForm(); addAccountForm.userAdded += AddAccountForm_userAdded; new Thread(RenderAccounts).Start(); }
private void validCreateAccount(AddAccountForm form) { try { accountRepo.GetAccounts().First(c => c.IBAN == form.IBAN); ModelState.AddModelError("IBAN", "IBAN déja attribué"); } catch (Exception) { } }
public void AddAccountTest1() { //Arrange BankController.Session[Utils.SessionBanker] = bankers[0]; AddAccountForm form = new AddAccountForm(); form.BIC = "23YT"; form.IBAN = "FR9552102565062826225126616"; CustomerRepo.Setup(r => r.GetCustomerByID(bankers[0].ID)).Returns(customers[0]); CustomerRepo.Setup(r => r.Save()); //Act var result = BankController.AddAccount(form) as RedirectToRouteResult; //Assert Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); }
private void button16_Click(object sender, EventArgs e) { Form addAccountForm = new AddAccountForm(); addAccountForm.ShowDialog(); }