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 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));
        }