コード例 #1
0
 // 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;
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 public bool CreateUser(ApplicationUser user, string password)
 {
     var idResult = _userManager.Create(user, password);
     return idResult.Succeeded;
 }
コード例 #4
0
 public IdentityResult CreateUser(ApplicationUser user, string password)
 {
     return _userManager.Create(user, password);
 }
コード例 #5
0
 // 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);
     }
 }
コード例 #6
0
        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;
            }
        }
コード例 #7
0
 // 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;
 }