public ActionResult generateTills(AccIndexer form) { if (!ModelState.IsValid) { return(View("generateTill", form)); } var number = form.SelectTillsAmount.number; var glCategory = _content.acctIndex.SingleOrDefault(m => m.id == 20); //To get cash asset GL Account info for (int i = 0; i < number; i++) { var till = new TillGenerate().GetTillCode(glCategory.accountCode); //To generate till account code for till var count = _content.tellerDetails.Count(); //To log till account details for the newly created till account var stud = new TellerDetails { tillAccountNumber = till.ToString(), tillBalance = 0, tellerUsername = "******" + (count + 1) + "" }; _content.tellerDetails.Add(stud); _content.SaveChanges(); } TempData["Success"] = "New Till Account(s) Successfully Created."; //To display a success message to the user return(RedirectToAction("AcctLog", "Accounts", new { id = 20 })); }
public ActionResult UpdateTill(TellerDetails dt) { if (!ModelState.IsValid) { return(View("EditTill", dt)); } if (dt.amountToAdd <= 0) { TempData["Error"] = "Amount to add must not be negative or zero"; //To display an error message to the user. return(View("EditTill", dt)); } var tellerInDb = _content.tellerDetails.SingleOrDefault(m => m.Id == dt.Id); //To fetch till details from the database. if (tellerInDb == null) { return(HttpNotFound()); } else { var vaultAccountBal = _content.acctIndex.SingleOrDefault(m => m.id == 26); //To get vault's current account details if (dt.amountToAdd >= vaultAccountBal.amountInAcct) //Verify that there is enough fund in bank's account to fund teller's till accounts { TempData["Error"] = "Insufficient funds in the vault account"; //Display error message to the user return(View("EditTill", dt)); } vaultAccountBal.amountInAcct = vaultAccountBal.amountInAcct - dt.amountToAdd; //Debit Bank's Account tellerInDb.tillBalance = tellerInDb.tillBalance + dt.amountToAdd; //Credit Teller till's account. //Log transaction into database.s TillLog till = new TillLog(); till.accountEntry = "Credit"; till.accountSending = vaultAccountBal.accountName; till.accountRecieving = dt.tellerUsername + "(" + dt.tillAccountNumber + ")"; till.amount = dt.amountToAdd; till.dateOfTransaction = DateTime.Now; _content.tillLog.Add(till); var accountIndex = _content.acctIndex.SingleOrDefault(m => m.id == 20); accountIndex.amountInAcct = accountIndex.amountInAcct + dt.amountToAdd; } _content.SaveChanges(); TempData["Success"] = "Till Account Credited Successfully"; //To display success message to the user return(RedirectToAction("Details", "Tellers", new { id = dt.tillAccountNumber })); }
public async Task <ActionResult> Register(AccIndexer model) { var psd = "put your password here"; if (ModelState.IsValid) { var glCategory = _content.acctIndex.SingleOrDefault(m => m.id == 20); var till = new TillGenerate().GetTillCode(glCategory.accountCode); if (model.reg.role == "Plain User") { till = String.Empty; } var password = new PasswordGenerate().GetNewPassword(); model.reg.Password = password + "&zA1"; model.reg.ConfirmPassword = password + "&zA1"; var tempLocation = _content.stat.SingleOrDefault(m => m.id == 1); var tempStorePassword = model.reg.Password; tempLocation.temPassword = tempStorePassword; _content.SaveChanges(); var user = new ApplicationUser { UserName = model.reg.Email, Email = model.reg.Email, Branch = model.reg.Branch, tillAccount = till, PhoneNumber = model.reg.PhoneNumber, homeAddress = model.reg.HouseAddress, fullName = model.reg.FullName, role = model.reg.role }; //return Content(model.reg.Email); var result = await UserManager.CreateAsync(user, model.reg.Password); if (result.Succeeded) { //await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false); //Temp Code = Teller account if (model.reg.role == "Teller") { var roleStore = new RoleStore <IdentityRole>(new CoreBankingApplication.Data.ApplicationDbContext()); var roleManager = new RoleManager <IdentityRole>(roleStore); await roleManager.CreateAsync(new IdentityRole("Teller")); await UserManager.AddToRoleAsync(user.Id, "Teller"); } //Temp Code == Ends if (model.reg.role == "Teller") { var stud = new TellerDetails { tillAccountNumber = till, tillBalance = 0, tellerUsername = model.reg.Email, tillStatus = true }; _content.tellerDetails.Add(stud); _content.SaveChanges(); } if (model.reg.Email != null && model.reg.Password != null) { new SendEmail().SendingEmail(model.reg.Email, model.reg.Password, psd); } // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); TempData["Success"] = "New User Successfully Created."; return(RedirectToAction("Index", "Users")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }