// Allow Initialization with an instance of SYSTEM_USER: public EditUserViewModel(SYSTEM_USER user) { this.UserName = user.UserName; this.FirstName = user.FirstName; this.LastName = user.LastName; this.Email = user.Email; }
// Return a pre-poulated instance of AppliationUser: public SYSTEM_USER GetUser() { var user = new SYSTEM_USER() { UserName = this.UserName, FirstName = this.FirstName, LastName = this.LastName, Email = this.Email, CreatedDate = DateTime.Now }; return(user); }
// Enable initialization with an instance of SYSTEM_USER: public SelectUserRolesViewModel(SYSTEM_USER user) : this() { this.UserName = user.UserName; this.FirstName = user.FirstName; this.LastName = user.LastName; var Db = new ApplicationDbContext(); var um = new UserManager <SYSTEM_USER>( new UserStore <SYSTEM_USER>(new ApplicationDbContext())); var dbUser = um.FindById(user.Id); // Add all available roles to the list of EditorViewModels: var allRoles = Db.Roles; foreach (var role in allRoles) { var rvm = new SelectRoleEditorViewModel(role); this.Roles.Add(rvm); } //Set the Selected property to true for those roles for //which the current user is a member: if (user.SYSTEM_USER_ROLE.Count > 0) { foreach (var userRole in user.SYSTEM_USER_ROLE) { var checkUserRole = this.Roles.Find(r => r.RoleName == userRole.SYSTEM_ROLE.Name); checkUserRole.Selected = true; } } }
public bool CreateUser(SYSTEM_USER user, string password) { var idResult = _userManager.Create(user, password); return(idResult.Succeeded); }