public ActionResult saveProfile(AccIndexer form) { if (!ModelState.IsValid) { return(View("editU", form)); } else { var profile = _content.Users.SingleOrDefault(m => m.Id.ToString() == form.ApplicationUser.Id.ToString()); //To load selected user details from the database. if (profile == null) //To verify that profile exist { TempData["Error"] = "User Profile Does not exist."; //To display an error message to the user return(View("editU", form)); } else { //To update user details profile.Branch = form.ApplicationUser.Branch; profile.homeAddress = form.ApplicationUser.homeAddress; profile.fullName = form.ApplicationUser.fullName; profile.Email = form.ApplicationUser.Email; profile.PhoneNumber = form.ApplicationUser.PhoneNumber; _content.SaveChanges(); //To save update changes to database } } TempData["Success"] = "Update Successful"; return(RedirectToAction("Index", "Users")); }
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 assignTellerTill(AccIndexer form) { if (!ModelState.IsValid) { return(View("assignT", form)); } //To Fetch Till Account and User Profile Details var tillAccount = _content.tellerDetails.SingleOrDefault(m => m.tellerUsername == form.AssignTill.tillAccount); var profile = _content.Users.SingleOrDefault(m => m.UserName == form.AssignTill.profile); //To Assign Teller Role to the user var roleStore = new RoleStore <IdentityRole>(new CoreBankingApplication.Data.ApplicationDbContext()); var roleManager = new RoleManager <IdentityRole>(roleStore); roleManager.CreateAsync(new IdentityRole("Teller")); UserManager.AddToRole(profile.Id, "Teller"); //To Assign Till Account to the user profile.tillAccount = tillAccount.tillAccountNumber; profile.role = "Teller"; tillAccount.tellerUsername = profile.UserName; tillAccount.tillStatus = true; _content.SaveChanges(); TempData["Success"] = "Till Account Assigned Successfully"; return(RedirectToAction("Index", "Users")); }
public ActionResult CreateProfilee(AccIndexer form) { if (!ModelState.IsValid) { TempData["Error"] = "Error Creating Customer Profile,pls check inputs and try again."; //Displaying Error message to the user. return(RedirectToAction("CreateProfile", "Customers")); } else { var checkName = _content.custom.SingleOrDefault(m => m.customerName == form.Customer.customerName); if (checkName != null) { TempData["Error"] = "Customer Name Already exists in the database."; //Displaying Error message to the user. return(View("CreateProfile", form)); } var checkEmail = _content.custom.SingleOrDefault(m => m.customerEmail == form.Customer.customerEmail); //To check that customer email doesn't already exist in the database. if (checkEmail != null) { TempData["Error"] = "Customer Email Already exists in the database, pls use another email."; //Displaying Error message to the user. return(View("CreateProfile", form)); } //To add new customer profile to the database _content.custom.Add(form.Customer); _content.SaveChanges(); TempData["Success"] = "Customer Profile Created Successfully"; //Displaying Success message to the user. return(RedirectToAction("Index", "Customers")); } }
public ActionResult SaveGLUpdate(AccIndexer form) { if (ModelState.IsValid) { var glAcct = _content.acctIndex.SingleOrDefault(m => m.id == form.AccountIndex.id); //To load selected GL Account details if (glAcct == null) //To Verify GL Account exists. { return(View("EditAcc", form)); } else { //To Save GL Acccount Details to Database glAcct.accountBranch = form.AccountIndex.accountBranch; glAcct.accountName = form.AccountIndex.accountName; glAcct.accountDescription = form.AccountIndex.accountDescription; _content.SaveChanges(); TempData["Success"] = "GL Account Updated Successfully!"; //To Display a success message to user return(RedirectToAction("Index", "Accounts")); //To return view back to the index page. } } else { TempData["Error"] = "Invalid Request"; //To Display error message to the user. return(View("EditAcc", form)); } }
public ActionResult CreateGL(AccIndexer form) { if (!ModelState.IsValid) { return(View("CreateGLAccount", form)); //Return View if model state is not valid with the form contents. } else { var checkAcctName = _content.acctIndex.SingleOrDefault(m => m.accountName == form.AccountIndex.accountName); if (checkAcctName != null) { TempData["Error"] = "Sorry account Name already exists in the database"; return(View("CreateGLAccount", form)); } var glCategory = _content.subCategory.SingleOrDefault(m => m.id == form.AccountIndex.SubCategoryid); //Get Selected Sub GL Category details from the database. var mainGL = glCategory.glCategoryId; //To get the Main GL category id. form.AccountIndex.mainGLCategory = mainGL; //Save Main GL category id to GL Account Table. Random rn = new Random(); int unique = _content.acctIndex.Count(); int addUnique = unique + 1; //Generate a unique number to make account code unique. int generaterTill = rn.Next(000, 999); //Generate Random Numbers string code = form.AccountIndex.mainGLCategory + "" + generaterTill + "" + addUnique; //Creating account code for GL Account. form.AccountIndex.accountCode = code; form.AccountIndex.amountStatus = "NAIRA"; form.AccountIndex.dateCreated = DateTime.Now; _content.acctIndex.Add(form.AccountIndex); _content.SaveChanges(); TempData["Success"] = "GL Account Created Successfully!"; //Display Success message to user. return(RedirectToAction("Index", "Accounts")); //Return view back to index page } }
//GET: To generate till accounts public ActionResult generateTill() { var vm = new AccIndexer { SelectTillsAmount = new SelectTillsAmount() }; return(View(vm)); }
// GET: Users public ActionResult Index() { var _users = _content.Users.ToList(); var vm = new AccIndexer { userT = _users }; return(View(vm)); }
public ActionResult Register() { var roles = _content.uRole.ToList(); var vm = new AccIndexer { reg = new RegisterViewModel(), uRolee = roles }; return(View(vm)); }
// GET: Accounts public ActionResult Index() { //var info = _content.acctIndex.Include(m => m.mainGLCategory).ToList(); var acctIndex = _content.acctIndex.ToList(); var mainGlCategory = _content.glCategory.ToList(); var vm = new AccIndexer { type = mainGlCategory, AccountT = acctIndex }; return(View(vm)); }
//GET: To assign till account public ActionResult assignT() { var users = _content.Users.Where(m => m.tillAccount == String.Empty).ToList(); //Get all the users from the database var tills = _content.tellerDetails.Where(m => m.tillStatus == false).ToList(); //Get all the till accounts from the database var vm = new AccIndexer { userT = users, tillT = tills, AssignTill = new AssignTill() }; return(View(vm)); }
public ActionResult saveGLCategory(AccIndexer form) { if (!ModelState.IsValid) { return(View("EditSubL", form)); //Return View if model state is not valid with the form contents. } else { var selectedGL = _content.subCategory.SingleOrDefault(m => m.id == form.SubCategory.id); //To Load selected GL Category from the database. //Saving GL Category updates to the database. selectedGL.categoryName = form.SubCategory.categoryName; selectedGL.accountDescription = form.SubCategory.accountDescription; _content.SaveChanges(); TempData["Success"] = "Update Successful"; //To Display Success message to the viewer return(RedirectToAction("ViewSubGL", "Accounts")); //To return user back to the GL Category index view. } }
public ActionResult CreateCategoryGL(AccIndexer form) { if (!ModelState.IsValid) { return(View("CreateSubCategory", form)); //Return View if model state is not valid with the form contents. } else { var checkName = _content.subCategory.SingleOrDefault(m => m.categoryName == form.SubCategory.categoryName); if (checkName != null) { TempData["Error"] = "Sorry Category Name already exists in the database."; return(View("CreateSubCategory", form)); } _content.subCategory.Add(form.SubCategory); //Add new GL Category to database. _content.SaveChanges(); //Save Changes to database. TempData["Success"] = "GL Category Created Successfully!"; //Display Success message to user. return(RedirectToAction("ViewSubGL", "Accounts")); //To return view back to the index page. } }
public ActionResult saveEdit(AccIndexer form) { var acctEdit = _content.customAccts.SingleOrDefault(m => m.id == form.CustomerAccounts.id); //To load selected account details from the database. if (!ModelState.IsValid) { return(View("editAcct", form)); } if (form.CustomerAccounts.lien < 0) { TempData["Error"] = "Lien Amount must not be negative"; return(View("editAcct", form)); } if (form.CustomerAccounts.interestRate < 1 || form.CustomerAccounts.interestRate > 100) { TempData["Error"] = "Interest Rate must be between the range 1 to 100"; return(View("editAcct", form)); } if (acctEdit == null) //To verify account exists { return(View("editAcct", form)); } else { form.CustomerAccounts.interestRate = form.CustomerAccounts.interestRate / 100; //Save updates to the customer account details acctEdit.branchCreated = form.CustomerAccounts.branchCreated; if (form.CustomerAccounts.customerAccountType != "Phoenix Loan Account") { acctEdit.lien = form.CustomerAccounts.lien; } acctEdit.interestRate = form.CustomerAccounts.interestRate; _content.SaveChanges(); //To save changes to the database. } TempData["Success"] = "Update Successful"; //To display success message. return(RedirectToAction("CustomerAccounts", "Customers")); }
public ActionResult CreateAccount(AccIndexer form) { if (!ModelState.IsValid) { return(View("assignAccount", form)); } if (form.CustomerAccounts.accountBalance < 0) { TempData["Error"] = "Account Balance can't be below zero"; //To Display Error message to the user. return(View("assignAccount", form)); } if (form.CustomerAccounts.interestRate < 1 || form.CustomerAccounts.interestRate > 100) { TempData["Error"] = "Interest Rate Must Be between 1 to 100"; //To Display Error message to the user. return(View("assignAccount", form)); } form.CustomerAccounts.cot = 5; //Assign cot percentage o customer current account configuration var verufyProfile = _content.custom.SingleOrDefault(m => m.id == form.CustomerAccounts.CustomerID); //To get customer profile from the database. if (verufyProfile == null) //To verify that customer profile exists. { TempData["Error"] = "Customer Profile Does not exist in the database"; //To Display Error message to the user. return(View("assignAccount", form)); } else { form.CustomerAccounts.accountName = verufyProfile.customerName; if (form.CustomerAccounts.linkAcctType != null || form.CustomerAccounts.linkedAcctNumber != null) //To check if account is linked to the current account being created. { var verifyLink = _content.customAccts.SingleOrDefault(m => m.customerAccountType == form.CustomerAccounts.linkAcctType && m.customerAccountNumber == form.CustomerAccounts.linkedAcctNumber && m.CustomerID == form.CustomerAccounts.CustomerID); //Get Linked Account details from the database. if (verifyLink == null) //To verify that linked account exist { TempData["Error"] = "Customer Linked Account Does not exist."; //To Display Error message to the user. return(View("CreateLoanAccount", form)); } else { var checkForLoan = _content.customAccts.SingleOrDefault(m => m.CustomerID == form.CustomerAccounts.CustomerID && m.accountName == form.CustomerAccounts.accountName && m.customerAccountType == "Phoenix Loan Account"); //To check if customer already has an active loan account. if (checkForLoan != null) //To verify customer does not have an active loan account. { TempData["Error"] = "Customer Already has a loan account"; //To Display Error message to the user. return(View("assignAccount", form)); } if (form.CustomerAccounts.customerAccountType == "Phoenix Loan Account") { if (form.CustomerAccounts.months > 0) { var bankAcct = _content.acctIndex.SingleOrDefault(m => m.id == 13); //To load bank's account details from the database. if (bankAcct.amountInAcct <= form.CustomerAccounts.accountBalance) //To check if bank has enough money to give out as loan. { TempData["Error"] = "Bank's Account Too Low to process Loan"; //To Display Error message to the user. return(View("assignAccount", form)); } if (form.CustomerAccounts.accountBalance < 2000) { TempData["Error"] = "Not allowed to give loan lower than 2000 nair"; //To Display Error message to the user. return(View("assignAccount", form)); } //Getting Account Configuration var interestRate = (form.CustomerAccounts.interestRate / 100); var amount = form.CustomerAccounts.accountBalance; var duration = form.CustomerAccounts.months; var realAmt = form.CustomerAccounts.accountBalance; //Calculating Interest Rate / Income from customer loan account var calcIncome = (interestRate * realAmt) * duration; var totalSum = calcIncome + realAmt; verifyLink.accountBalance = verifyLink.accountBalance + realAmt; //Crediting customer's linked account with the amount loaned bankAcct.amountInAcct = bankAcct.amountInAcct - realAmt; //Debiting bank's account with the amount loaned var acctype = _content.acctIndex.SingleOrDefault(m => m.id == 12); var accountN = new AccountFunction().AccountNumber(acctype.accountCode, verufyProfile.id); //Generating account number for customer's loan account //Saving Customers loan account and configurations to database. form.CustomerAccounts.customerAccountNumber = accountN; form.CustomerAccounts.accountBalance = (double)totalSum; form.CustomerAccounts.dateCreated = DateTime.Now; form.CustomerAccounts.balanceStatus = "NAIRA"; form.CustomerAccounts.loanStatus = true; _content.customAccts.Add(form.CustomerAccounts); //Creating Customer loan interest account to keep track of the interest accrual LoanInterestAccrual loanAccured = new LoanInterestAccrual(); loanAccured.customerAcctName = form.CustomerAccounts.accountName; loanAccured.customerAcctNo = form.CustomerAccounts.customerAccountNumber; loanAccured.linkedAcctName = form.CustomerAccounts.linkAcctType; loanAccured.linkedAcctNo = form.CustomerAccounts.linkedAcctNumber; loanAccured.accruedAmt = 0.0; loanAccured.duration = form.CustomerAccounts.months; loanAccured.dateOfLoan = DateTime.Now; loanAccured.interestRate = interestRate / 30; loanAccured.loanAmount = totalSum; _content.loanAccrued.Add(loanAccured); //Creating Customer loan income account to keep track of the amount gained as ncome from customer loan loanIncome loan = new loanIncome(); loan.accountName = form.CustomerAccounts.accountName; loan.acctNo = form.CustomerAccounts.customerAccountNumber; loan.amountBorrowed = realAmt.ToString(); loan.incomeG = calcIncome.ToString(); loan.accruedInc = 0.0; loan.date = DateTime.Now; loan.duration = form.CustomerAccounts.months.ToString(); loan.rate = interestRate.ToString(); _content.loanI.Add(loan); var acctLoan = _content.acctIndex.SingleOrDefault(m => m.id == 9); acctLoan.amountInAcct = acctLoan.amountInAcct + totalSum; //Crediting Customer Loan Account. var linkedAcct = _content.acctIndex.SingleOrDefault(m => m.accountName == verifyLink.accountName); if (linkedAcct != null) { linkedAcct.amountInAcct = linkedAcct.amountInAcct + realAmt; } _content.SaveChanges(); //Saving all changes to the database } else { TempData["Error"] = "Pls Specify Loan Duration"; //To Display Error message to the user. return(View("CreateLoanAccount", form)); } } } } else if (form.CustomerAccounts.linkAcctType == null && form.CustomerAccounts.linkedAcctNumber == null) { if (form.CustomerAccounts.customerAccountType == "Phoenix Loan Account") { TempData["Error"] = "Pls Specify Customer Linked Accounts"; //To Display error message to the user. return(View("CreateLoanAccount", form)); } var acctype = _content.acctIndex.SingleOrDefault(m => m.accountName == form.CustomerAccounts.customerAccountType); //Generating Account Number for th customer account var accountN = new AccountFunction().AccountNumber(acctype.accountCode, verufyProfile.id); //Assigning Account Number to the customer account //Saving Customer account and configurations to the database form.CustomerAccounts.customerAccountNumber = accountN; form.CustomerAccounts.accountBalance = (double)form.CustomerAccounts.accountBalance; form.CustomerAccounts.dateCreated = DateTime.Now; form.CustomerAccounts.balanceStatus = "NAIRA"; acctype.amountInAcct = acctype.amountInAcct + form.CustomerAccounts.accountBalance; form.CustomerAccounts.loanStatus = true; form.CustomerAccounts.interestRate = form.CustomerAccounts.interestRate / 100; _content.customAccts.Add(form.CustomerAccounts); _content.SaveChanges(); //Saving Changes to the database. } } TempData["Success"] = "Account Created Successfully"; //To Display Success message to the user. return(RedirectToAction("CustomerAccounts", "Customers")); }
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)); }