Exemplo n.º 1
0
        public async Task<IdentityResult> CreateUserAsync()
        {
            var context = new ApplicationDbContext();

            var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context));

            return await userManager.CreateAsync(new ApplicationUser());
        }
Exemplo n.º 2
0
        public async Task<ApplicationUser> GetUserByIdAsync(string userId)
        {
            var context = new ApplicationDbContext();

            var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context));

            return await userManager.FindByIdAsync(userId);
        }
Exemplo n.º 3
0
        public async Task<IdentityResult> AssignRoleAsync(string userid, string role)
        {
            var context = new ApplicationDbContext();

            var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context));

            return await userManager.AddToRoleAsync(userid, role);
        }