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


C# MembershipProvider.DeleteUser方法代码示例

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


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

示例1: DeleteUser

        public void DeleteUser()
        {
            CreateUserWithHashedPassword();
            Assert.IsTrue(provider.DeleteUser("foo", true));
            var count = _db.GetCollection<User>(provider.CollectionName).Count();
            Assert.AreEqual(0, count);

            provider = new MembershipProvider();
            CreateUserWithHashedPassword();

            // in Mongo, all associated data is stored in same document so
            // passing true or false to DeleteUser will be the same.
            Assert.IsTrue(provider.DeleteUser("foo", deleteAllRelatedData: true));
            count = _db.GetCollection<User>(provider.CollectionName).Count();
            Assert.AreEqual(0, count);
            //Assert.IsTrue(Membership.DeleteUser("foo", false));
            //table = FillTable("SELECT * FROM my_aspnet_Membership");
            //Assert.AreEqual(0, table.Rows.Count);
            //table = FillTable("SELECT * FROM my_aspnet_Users");
            //Assert.AreEqual(1, table.Rows.Count);
        }
开发者ID:netdragoon,项目名称:MongoProviders,代码行数:21,代码来源:MembershipProviderTest.cs

示例2: CreateUserAccount

        public static string CreateUserAccount(MembershipProvider userMembershipProvider, User user)
        {
            string error = "";

            user.Email = user.Email.ToLower();

            User validateUser = UserService.GetUserByUsername(user.Username);
            if (validateUser.UserID > 0)
                return UserMessages.UsernameAlreadyUsed;

            validateUser = UserService.GetUserByEmail(user.Email);
            if (validateUser.UserID > 0)
                return UserMessages.EmailAlreadyUsed;

            MembershipCreateStatus status;
            MembershipUser mu = userMembershipProvider.CreateUser(user.Email, user.Password, user.Email, null, null, true, null, out status);

            if (status != MembershipCreateStatus.Success)
                return UserMessages.ErrorCreatingAccount;

            user.AspnetUserID = (Guid)mu.ProviderUserKey;

            int userID = CreateUserAccount(user);

            if(userID == 0)
            {
                // Delete user account
                userMembershipProvider.DeleteUser(user.Email, true);
                return UserMessages.ErrorCreatingAccount;
            }

            user.UserID = userID;

            return error;
        }
开发者ID:nagaveeram,项目名称:MnDayCare,代码行数:35,代码来源:User.cs


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