Ejemplo n.º 1
0
        public IdentityResult Register(AccountModelDAL model)
        {
            var userStore = new UserStore <User>(new UserContext());
            var manager   = new UserManager <User>(userStore);
            var user      = new User()
            {
                UserName = model.UserName, Email = model.Email
            };

            user.FirstName            = model.FirstName;
            user.LastName             = model.LastName;
            manager.PasswordValidator = new PasswordValidator
            {
                RequiredLength = 3
            };
            IdentityResult result      = manager.Create(user, model.Password);
            var            currentUser = manager.FindByName(user.UserName);

            manager.AddToRoles(currentUser.Id, model.Roles);
            return(result);
        }
Ejemplo n.º 2
0
        public IdentityResult Register(AccountModelDTO model)
        {
            AccountModelDAL modelDAL = new AccountModelDAL();

            modelDAL.Email     = model.Email;
            modelDAL.FirstName = model.FirstName;
            modelDAL.LastName  = model.LastName;
            modelDAL.Password  = model.Password;
            modelDAL.UserName  = model.UserName;
            modelDAL.Roles     = model.Roles;
            var result = Database.Users.Register(modelDAL);

            //var userStore = new UserStore<User>(new UserContext());
            //var manager = new UserManager<User>(userStore);
            //var user = new User() { UserName = model.UserName, Email = model.Email };
            //user.FirstName = model.FirstName;
            //user.LastName = model.LastName;
            //manager.PasswordValidator = new PasswordValidator
            //{
            //    RequiredLength = 3
            //};
            //IdentityResult result = manager.Create(user, model.Password);
            return(result);
        }
Ejemplo n.º 3
0
 public IdentityResult Register(AccountModelDAL model)
 {
     return(null);
 }