当前位置: 首页>>代码示例>>C#>>正文


C# UserManager.Delete方法代码示例

本文整理汇总了C#中UserManager.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# UserManager.Delete方法的具体用法?C# UserManager.Delete怎么用?C# UserManager.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserManager的用法示例。


在下文中一共展示了UserManager.Delete方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveUser

 internal bool RemoveUser(string username)
 {
     Models.ApplicationDbContext context = new Models.ApplicationDbContext();
     var userMgr = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context));
     userMgr.Delete(userMgr.FindByName(username));
     return true;
 }
开发者ID:OurFirstOrgan,项目名称:FlyingSnow.Travel,代码行数:7,代码来源:RoleActions.cs

示例2: Delete

 public void Delete(ApplicationUser user)
 {
     var userStore = new UserStore<ApplicationUser>(this.Context);
     var userManager = new UserManager<ApplicationUser>(userStore);
     userManager.Delete(user);
     var context = userStore.Context;
     context.SaveChanges();
 }
开发者ID:ivanvasilev,项目名称:PickUp,代码行数:8,代码来源:UsersService.cs

示例3: grvUsers_RowDeleting

        protected void grvUsers_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            var id = grvUsers.DataKeys[e.RowIndex].Value.ToString();

            var userStore = new UserStore<IdentityUser>();
            var userManager = new UserManager<IdentityUser>(userStore);
            var user = userManager.FindById(id);

            if (user != null && user.UserName != "Admin")
            {
                userManager.Delete(user);
            }

            if (id == SharedClass.CurrentUser)
            {
                Response.Redirect("~/Login.aspx?Logout=true");
            }
        }
开发者ID:manili,项目名称:Medical_Clinic,代码行数:18,代码来源:User_Management.aspx.cs

示例4: CleanUp

 private void CleanUp(IdentityUser user, UserManager<IdentityUser, Guid> manager)
 {
     var result = manager.Delete(user);
     if (!result.Succeeded)
         throw new Exception("Failed to delete Identity");
 }
开发者ID:karosas,项目名称:Congregatio,代码行数:6,代码来源:UserServiceTests.cs

示例5: DeleteUser

        public bool DeleteUser(string id)
        {
            var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
            var user = manager.FindById(id);

            var success=manager.Delete(user);
            if(success.Succeeded)
                return true;

            return false;
        }
开发者ID:choob207,项目名称:The-Final-project,代码行数:11,代码来源:Repository.cs

示例6: PostEmployee

        public IHttpActionResult PostEmployee(Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var userStore = new UserStore<IdentityUser>();
            var manager = new UserManager<IdentityUser>(userStore);

            var user = new IdentityUser() { UserName = employee.Email, Email = employee.Email, PhoneNumber = employee.PrimaryMobile.ToString() };

            // TODO Environment Varialbe

            IdentityResult result = manager.Create(user, WebConfigurationManager.AppSettings["DefaultPassword"]);

            // IdentityResult result = manager.Create(user, Environment.GetEnvironmentVariable("DefaultPassword"));

            string[] roles =  { "", "", "", "", "ClientEmployee", "ClientAdmin", "OrgEmployee", "OrgManager", "SecondLevelManager" };
            int roleIndex = employee.EmpStatus;
            if (result.Succeeded)
            {
                employee.AuthUserId = user.Id;
                employee.ProfilePic = "0";
                employee.EmpStatus = 1;
                db.Employees.Add(employee);

                if (db.SaveChanges() != 1)
                {
                     manager.Delete(user);
                }
                else
                {
                    //manager.AddToRole(employee.AuthUserId, "ClientEmployee");
                    manager.AddToRole(employee.AuthUserId, roles[roleIndex]);
                }
            }
            return CreatedAtRoute("DefaultApi", new { id = employee.EmpId }, employee);
        }
开发者ID:GenieHR,项目名称:geniehr-adminpanel,代码行数:39,代码来源:EmployeesController.cs

示例7: deleteUser

        public ActionResult deleteUser(string userID)
        {
            ajaxReturnData data = new ajaxReturnData();

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {
                    ApplicationUser user = new ApplicationUser();

                    var store = new UserStore<ApplicationUser>(DB);
                    UserManager<ApplicationUser> um = new UserManager<ApplicationUser>(store);
                    user = um.FindById(userID);
                    if (user.UserName == "[email protected]")
                    {
                        data.statusCode = (int)statusCodes.fail;
                        data.message = "I'm sorry Dave, I'm afraid I can't do that";
                    }
                    else {
                        DB.UserLanguages.RemoveRange(DB.UserLanguages.Where(x => x.userID == userID));
                        data.message = "User '" + user.UserName + "' has become one with the void";
                        um.Delete(user);
                        data.statusCode = (int)statusCodes.successRun;
                    }
                    
                }

            }
            catch (Exception ex)
            {

                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to delete user; Error is: " + ex.Message;
            }



            return Json(data);
        }
开发者ID:GoGoNihon,项目名称:nihonMVC,代码行数:39,代码来源:APIUserController.cs

示例8: KullaniciSil

 public ActionResult KullaniciSil(string id)
 {
     UserStore<HaberUser> userStore = new UserStore<HaberUser>(context);
     userManager = new UserManager<HaberUser>(userStore);
     if (id==null || id=="")
     {
         return RedirectToAction("KullaniciListesi");
     }
     else
     {
         var user = userManager.FindByName(id.Trim());
         if (user!=null)
         {
             userManager.Delete(user);
             context.SaveChanges();
             
         }
             return RedirectToAction("KullaniciListesi");
     }
 }
开发者ID:dgncn,项目名称:Haber,代码行数:20,代码来源:DashboardController.cs

示例9: TenantDelete

        public JsonResult TenantDelete(string TenantID)
        {

            var BID = db.Tenant.Where(c => c.ID == TenantID).FirstOrDefault().Apartment.Buildings.ID;
            var AID = db.Tenant.Where(c => c.ID == TenantID).FirstOrDefault().Apartment.ID;


            try {
              
                
                ApplicationDbContext context = new ApplicationDbContext();
                ApplicationUser AppUser = new ApplicationUser();
                var RoleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(context));
                var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context));
                // remove tenant from role
                userManager.RemoveFromRole(TenantID, "Tenant");
                //find tenant on the tenant table 
                 AspNetUsers aspnetuser = db.AspNetUsers.Find(TenantID);
                db.AspNetUsers.Remove(aspnetuser);
                var tn = db.Tenant.Find(TenantID);
                //remove tenant from the tenant table
                db.Tenant.Remove(tn);
                //save changes 
                db.SaveChanges();
                //load tenant applicationuser 
                AppUser = userManager.FindById(TenantID);
                //delete tenant applicationuser
                var result = userManager.Delete(AppUser);

              
               
            }
            catch (Exception e)
            {
                ViewBag.Message = e.Message;

            }

            var tenants = db.Tenant.Where(c => c.aptID == (int?)AID).Select(c => new
            {
                ID = c.ID,
                FirstName = c.FirstName,
                LastName = c.LastName,
                Phone = c.Phone,
                UserName = c.Username,
                CreatedDate = c.Created
            }).ToList();

            var mydata = Json(tenants);

            return new JsonResult { Data = mydata, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
               
        }
开发者ID:dioscarr,项目名称:PointerSecurityMonitor,代码行数:53,代码来源:BuildingController.cs

示例10: removeSSAEktronMember

    public void removeSSAEktronMember(string UserPIN)
    {
        try
        {
            UserManager Usermanager = new UserManager();
            UserCriteria criteria = new UserCriteria(UserProperty.UserName, EkEnumeration.OrderByDirection.Ascending);

            criteria.AddFilter(UserProperty.UserName, CriteriaFilterOperator.EqualTo, UserPIN);

            List<UserData> UserList = Usermanager.GetList(criteria);
            long EktronUserID = UserList[0].Id;

            if (Ektron.Cms.Framework.Context.UserContextService.Current.IsLoggedIn)
            {
                Usermanager.Delete(EktronUserID);
                // add user to group MSBA Members
                //UserGroupManager UserGroupmanager = new UserGroupManager();
                //Add a User  to a UserGroup
                // UserGroupmanager.DeleteUser(1, newUserdata.Id);
            }
        }
        catch { }
    }
开发者ID:femiosinowo,项目名称:sssadl,代码行数:23,代码来源:view.aspx.cs


注:本文中的UserManager.Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。