public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Verify that the user is an Employee...
                var m = new Manager();

                if (m.IsNewUserAnEmployee(model.Email))
                {
                    // Attempt to register the user...

                    // Configure all the 'required' properties in the following statement
                    var user = new ApplicationUser { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName };

                    var result = await UserManager.CreateAsync(user, model.Password);
                    if (result.Succeeded)
                    {
                        // ##################################################

                        // Add claims

                        await UserManager.AddClaimAsync(user.Id, new Claim(ClaimTypes.Email, model.Email));
                        await UserManager.AddClaimAsync(user.Id, new Claim(ClaimTypes.GivenName, model.FirstName));
                        await UserManager.AddClaimAsync(user.Id, new Claim(ClaimTypes.Surname, model.LastName));
                        await UserManager.AddClaimAsync(user.Id, new Claim(ClaimTypes.Role, "Employee"));

                        // Configure the organization unit

                        m.ConfigureUserWithOU(model.Email, model.OU);

                        // ##################################################

                        await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                        // 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>");

                        return RedirectToAction("Index", "Home");
                    }
                    AddErrors(result);

                    // Create and configure a view model object
                    var registerFormWithError = new RegisterViewModelForm();

                    var ous = m.GetAllOUs();
                    registerFormWithError.OUList = new SelectList(ous, "OUName", "OUName", model.OU);

                    return View(registerFormWithError);

                }
                else
                {
                    ModelState.AddModelError("", "This person is not an Employee, and cannot create an account.");
                }
            }

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

            AutoMapper.Mapper.CreateMap<RegisterViewModel, RegisterViewModelForm>();

            var registerForm = AutoMapper.Mapper.Map<RegisterViewModelForm>(model);
            //registerForm.RolesList = new MultiSelectList(new List<string> { "Student", "Teacher", "Coordinator" }, model.Roles);

            return View(registerForm);
        }
        public ActionResult Register()
        {
            // Create and configure a view model object
            var registerForm = new RegisterViewModelForm();

            //registerForm.RolesList = new MultiSelectList(new List<string> { "Student", "Teacher", "Coordinator" });
            var ous = m.GetAllOUs();
            registerForm.OUList = new SelectList(ous, "OUName", "OUName", ous.First().OUName);

            return View(registerForm);
        }