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


C# UserRepository.GetUserById方法代码示例

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


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

示例1: ShouldCreateNewUserAndReturnHisId

        public void ShouldCreateNewUserAndReturnHisId()
        {
            var repo = new UserRepository();
            int userId = repo.CreateUser("user_name", "password", "name", "address", "phone");
            var user = repo.GetUserById(userId);

            Assert.IsNotNull(user);
            Assert.AreEqual("user_name",user.AccountName);
        }
开发者ID:VLysiuk,项目名称:FitnesseDemo,代码行数:9,代码来源:UserRepositoryTest.cs

示例2: ShouldReturnUserById

        public void ShouldReturnUserById()
        {
            const string accountName = "super_user";
            var repo = new UserRepository();
            repo.CreateUser("user_name1", "password", "name1", "address", "phone");
            repo.CreateUser(accountName, "password", "name2", "address", "phone");

            var bankUser = repo.GetUserById(1);

            Assert.AreEqual(accountName,bankUser.AccountName);
        }
开发者ID:VLysiuk,项目名称:FitnesseDemo,代码行数:11,代码来源:UserRepositoryTest.cs

示例3: ChangePassword

        public ActionResult ChangePassword(LocalPasswordModel model)
        {
            try
            {
                if (model.NewPassword.Equals(model.OldPassword))
                    throw new Exception("Please use some other password, New Password should not be same as old password.");

                var userRepository = new UserRepository();
                var user = userRepository.GetUserById(int.Parse(Session["PatientId"].ToString()));
                user.Password = model.NewPassword;
                userRepository.UpdatePassword(user);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return View(model);
            }
            return RedirectToLocal();
        }
开发者ID:ranjancse,项目名称:HealthReunionPatientPoral,代码行数:19,代码来源:AccountController.cs

示例4: GeneratePasswordResetToken

        public static string GeneratePasswordResetToken(string userName)
        {
            if (string.IsNullOrEmpty(userName))
            {
                throw new ArgumentException("Username cannot be empty");
            }

            var repo = new UserRepository();
            var userId = VerifyUserNameHasConfirmedAccount(userName, false);

            var user = repo.GetUserById(userId);

            if (user == null)
                return null;

            if (user.PasswordVerificationTokenExpirationDate.HasValue &&
                user.PasswordVerificationTokenExpirationDate.Value > DateTime.UtcNow)
            {
                return user.PasswordVerificationToken;
            }

            var token = GenerateToken();
            user.PasswordVerificationToken = token;
            user.PasswordVerificationTokenExpirationDate =
                DateTime.UtcNow.AddMinutes(TokenExpirationInMinutesFromNow);

            repo.Update(user);

            return token;
        }
开发者ID:vaadim,项目名称:yatdl,代码行数:30,代码来源:WebSecurity.cs

示例5: GetUser

        public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
        {
            if (providerUserKey == null)
            {
                throw new ArgumentNullException("providerUserKey");
            }

            if (!(providerUserKey is Guid))
            {
                throw new ArgumentException(SR.GetString(SR.Membership_InvalidProviderUserKey), "providerUserKey");
            }

            var dbo = new UserRepository(this.Name, _sqlConnectionString, _commandTimeout);
            var user = dbo.GetUserById(providerUserKey);

            if (user == null)
                return null;

            return new MembershipUser(this.Name,
                                 user.UserName,
                                 user.UserId,
                                 user.Email,
                                 user.PasswordQuestion,
                                 null,
                                 user.IsApproved,
                                 user.IsLockedOut,
                                 user.LastActivityDate,
                                 user.LastLoginDate.GetValueOrDefault(),
                                 user.LastLoginDate.GetValueOrDefault(),
                                 user.LastPasswordChangedDate.GetValueOrDefault(),
                                 user.LastLockoutDate.GetValueOrDefault());
        }
开发者ID:cwbrandsma,项目名称:OpenId-Provider,代码行数:32,代码来源:UnityMembershipProvider.cs


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