// original action was async, but the action was made synchronous because the 'await' operator was commented out below
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            // disable Register action; users can only be manually created by IdentityManager or UserManager roles
            //return RedirectToAction("Index", "Home");

            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { FirstName = model.FirstName, LastName = model.LastName, DeptID = model.DeptID, DivID = model.DivID, UserName = model.Email, Email = model.Email, AppModuleID = 1, IsActive = true };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    var rolesForUser = UserManager.GetRoles(user.Id);
                    if (!rolesForUser.Contains("CIPUser"))
                    {
                        // add user to CIPUser role
                        UserManager.AddToRole(user.Id, "CIPUser");
                    }

                    var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    string body;
                    using (var sr = new StreamReader(Server.MapPath("~/Templates/") + "NewUserRegistrationConfirmation.html"))
                    {
                        body = await sr.ReadToEndAsync();
                    }
                    string messageBody = string.Format(body, callbackUrl);
                    await UserManager.SendEmailAsync(user.Id, "Welcome New User", messageBody);
                    ViewBag.Link = callbackUrl;
                    return View("DisplayEmail");
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form

            // populate Dept/Div dropdowns
            AppGlobalSetting appGlobalSetting = await _unitOfWork.AppGlobalSettingRepository.GetFirstOrDefaultAsync();
            model.DeptsList = new SelectList(await _unitOfWork.DeptRepository.GetAsync(d => d.BudgetPeriodID == appGlobalSetting.BudgetPeriodID, q => q.OrderBy(d => d.Code)), "ID", "CompositeDeptName");
            model.DivsList = new SelectList(await _unitOfWork.DivRepository.GetAsync(d => d.BudgetPeriodID == appGlobalSetting.BudgetPeriodID, q => q.OrderBy(d => d.Code)), "ID", "CompositeDivName");

            return View(model);
        }
        public async Task<ActionResult> Register()
        {
            // disable Register action; users can only be manually created by IdentityManager or UserManager roles
            //return RedirectToAction("Index", "Home");
            RegisterViewModel viewModel = new RegisterViewModel();

            // populate Dept/Div dropdowns
            AppGlobalSetting appGlobalSetting = await _unitOfWork.AppGlobalSettingRepository.GetFirstOrDefaultAsync();
            viewModel.DeptsList = new SelectList(await _unitOfWork.DeptRepository.GetAsync(d => d.BudgetPeriodID == appGlobalSetting.BudgetPeriodID, q => q.OrderBy(d => d.Code)), "ID", "CompositeDeptName");
            viewModel.DivsList = new SelectList(await _unitOfWork.DivRepository.GetAsync(d => d.BudgetPeriodID == appGlobalSetting.BudgetPeriodID, q => q.OrderBy(d => d.Code)), "ID", "CompositeDivName");

            return View(viewModel);
        }