public string AddEmployees(RegisterViewModel model)
        {
            string feedback = "There Is Already An Employee With The Same Information";

            //Generate password
            string password = "******";//"SPBFI" + Guid.NewGuid().ToString().Substring(0, 8);

            //Generate Gender
            var gender = Convert.ToInt16(model.IdentityNumber.Substring(6, 1)) < 5 ? "Female" : "Male";

            //create user
            var user = new ApplicationUser
            {
                UserName = model.Email,
                Email = model.Email,
                UserProfile = new Employees
                {
                    UserProfileId = model.UserProfileId,
                    FirstName = model.FirstName,
                    LastName = model.LastName,
                    Gender = gender,
                    ContactNumber = model.ContactNumber,
                    Email = model.Email,
                    PhysicalAddress = model.PhysicalAddress,
                    IdentityNumber = model.IdentityNumber,
                    IsFirstTimeLogin = true,
                    Position = model.Position
                }
            };

            //create user in the aspnet table
            var result = UserManager.Create(user, password);

            if (result.Succeeded)
            {
                feedback = model.Email.Trim() + "~" + user.Id + "Hello! " + model.FirstName.Substring(0, 1) + ". " + model.LastName
                           + "<br/>The following are your log in credentials.<br/>"
                           + "UserName: "******"<br/>Password: "******"<br/><br>Please note that you are required to change password on your first time log in"
                           + "<br/>-----Email by SPBFI-System-----";

                //create role
                if (!RoleManager.RoleExists(model.Position))
                {
                    RoleManager.Create(new IdentityRole { Name = model.Position });
                }
                //assign user to role
                UserManager.AddToRole(user.Id, model.Position);
            }
            return feedback;
        }
        public async Task<ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl)
        {
            if (User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Manage");
            }

            if (ModelState.IsValid)
            {
                // Get the information about the user from the external login provider
                var info = await AuthenticationManager.GetExternalLoginInfoAsync();
                if (info == null)
                {
                    return View("ExternalLoginFailure");
                }
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
                var result = await UserManager.CreateAsync(user);
                if (result.Succeeded)
                {
                    result = await UserManager.AddLoginAsync(user.Id, info.Login);
                    if (result.Succeeded)
                    {
                        await SignInManager.SignInAsync(user, false, false);
                        return RedirectToLocal(returnUrl);
                    }
                }
                AddErrors(result);
            }

            ViewBag.ReturnUrl = returnUrl;
            return View(model);
        }