// Allow Initialization with an instance of ApplicationUser:
 public EditUserViewModel(ApplicationUser user)
 {
     this.UserName = user.UserName;
     this.FirstName = user.FirstName;
     this.LastName = user.LastName;
     this.Email = user.Email;
 }
 private async Task SignInAsync(ApplicationUser user, bool isPersistent)
 {
     AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
     var identity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
     AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
 }
 public bool CreateUser(ApplicationUser user, string password)
 {
     var idResult = _userManager.Create(user, password);
     return idResult.Succeeded;
 }
 public IdentityResult CreateUser(ApplicationUser user, string password)
 {
     return _userManager.Create(user, password);
 }
 // Enable initialization with an instance of ApplicationUser:
 public UserPermissionsViewModel(ApplicationUser user)
     : this()
 {
     this.UserName = user.UserName;
     this.FirstName = user.FirstName;
     this.LastName = user.LastName;
     foreach (var role in user.Roles)
     {
         var appRole = (ApplicationRole)role.Role;
         var pvm = new RoleViewModel(appRole);
         this.Roles.Add(pvm);
     }
 }
        public SelectUserGroupsViewModel(ApplicationUser user)
            : this()
        {
            this.UserName = user.UserName;
            this.FirstName = user.FirstName;
            this.LastName = user.LastName;

            var Db = new ApplicationDbContext();

            // Add all available groups to the public list:
            var allGroups = Db.Groups;
            foreach (var role in allGroups)
            {
                // An EditorViewModel will be used by Editor Template:
                var rvm = new SelectGroupEditorViewModel(role);
                this.Groups.Add(rvm);
            }

            // Set the Selected property to true where user is already a member:
            foreach (var group in user.Groups)
            {
                var checkUserRole =
                    this.Groups.Find(r => r.GroupName == group.Group.Name);
                checkUserRole.Selected = true;
            }
        }
 // Return a pre-poulated instance of AppliationUser:
 public ApplicationUser GetUser()
 {
     var user = new ApplicationUser()
     {
         UserName = this.UserName,
         FirstName = this.FirstName,
         LastName = this.LastName,
         Email = this.Email,
     };
     return user;
 }