コード例 #1
0
        public void enableAccount(ApplicationUser entity)
        {
            var userManager = new MujZavod.Data.Identity.ApplicationUserManager(
                new Microsoft.AspNet.Identity.EntityFramework.UserStore <MujZavod.Data.Identity.ApplicationUser>(Context));

            userManager.SetLockoutEnabled(entity.Id, false);
        }
コード例 #2
0
        public override void Remove(ApplicationUser entity, bool saveChanges)
        {
            var userManager = new MujZavod.Data.Identity.ApplicationUserManager(
                new Microsoft.AspNet.Identity.EntityFramework.UserStore <MujZavod.Data.Identity.ApplicationUser>(Context));

            /*
             * userManager.SetLockoutEnabled(entity.Id, true);
             * userManager.SetLockoutEndDate(entity.Id, new DateTime(3000, 1, 1));
             */

            userManager.Delete(entity);
        }
コード例 #3
0
        public void Create(ApplicationUser entity, string[] roles)
        {
            var userManager = new MujZavod.Data.Identity.ApplicationUserManager(
                new Microsoft.AspNet.Identity.EntityFramework.UserStore <MujZavod.Data.Identity.ApplicationUser>(Context));



            var result = userManager.Create(entity);

            result = userManager.SetLockoutEnabled(entity.Id, false);



            var rolesForUser = userManager.GetRoles(entity.Id);

            foreach (string role in roles)
            {
                if (!rolesForUser.Contains(role))
                {
                    var res = userManager.AddToRole(entity.Id, role);
                }
            }
        }