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


C# UserRepository.GetUser方法代码示例

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


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

示例1: Delete_ShouldDeleteUser

        public void Delete_ShouldDeleteUser()
        {
            //arrange
            var userRepository = new UserRepository(Properties.Resources.ConnectionString);
            User user = TestDataHelper.GenerateUser();

            //act
            userRepository.CreateUser(user);
            User userBeforeDelete = userRepository.GetUser(user.Id);
            if (userBeforeDelete == null)
            {
                Console.WriteLine("User not exist!");
            }
            else
            {
                Console.WriteLine("User exist.");
            }
            userRepository.DeleteUser(user.Id);

            //assert
            User userAfterDelete = userRepository.GetUser(user.Id);

            if (userAfterDelete == null)
            {
                Console.WriteLine("User deleted.");
            }
            else
            {
                Console.WriteLine("User not deleted!");
            }

            Assert.IsTrue(!(userBeforeDelete == null) & (userAfterDelete == null));
        }
开发者ID:Bot32,项目名称:MeetGenerator,代码行数:33,代码来源:UserRepositoryTest.cs

示例2: AddLastUser

 public void AddLastUser()
 {
     UserRepository repository = new UserRepository();
     User user = new User(ulong.MaxValue, "last");
     repository.SetUser(user);
     User result = repository.GetUser(user.Id);
     Assert.IsNotNull(result);
     Assert.AreEqual(user, result);
 }
开发者ID:ajlopez,项目名称:AjActivity,代码行数:9,代码来源:UserRepositoryTests.cs

示例3: LoginUserMessage

 private void LoginUserMessage(object obj)
 {
     var password = ((System.Windows.Controls.PasswordBox)obj).Password;
     _userRepo = new UserRepository();
     User user = _userRepo.GetUser(Username, password);
     if(user != null)
     {
         // MainViewModel should lisent to this
         Messenger.Default.Send<User>(user, "UserLogin");
     }
     Messenger.Default.Send<bool>(true, "CloseLoginView");
 }
开发者ID:tschafma,项目名称:Jukebox,代码行数:12,代码来源:LoginUserViewModel.cs

示例4: Get_ByEmail_ShouldReturnUser

        public void Get_ByEmail_ShouldReturnUser()
        {
            //arrange
            var userRepository = new UserRepository(Properties.Resources.ConnectionString);
            User user = TestDataHelper.GenerateUser();

            //act
            userRepository.CreateUser(user);
            var resultUser = userRepository.GetUser(user.Email);

            //asserts
            TestDataHelper.PrintUserInfo(resultUser);
            Assert.IsTrue(TestDataHelper.CompareUsers(user, resultUser));
        }
开发者ID:Bot32,项目名称:MeetGenerator,代码行数:14,代码来源:UserRepositoryTest.cs

示例5: btn_loginUser_Click

    protected void btn_loginUser_Click(object sender, EventArgs e)
    {
        UserRepository userR = new UserRepository();
        string password = txt_PasswordLogin.Text;
        string user = txt_UserLogin.Text;
        var obj = userR.GetUser(user, password);

            if (obj.IsAdmin == true)
                //navigate and set admin
                Response.Redirect("Admin_Home.aspx");
            else
                //navigate and set user
                Response.Redirect("User_Home.aspx");
    }
开发者ID:BeeryTC,项目名称:NMC_ASP_Final,代码行数:14,代码来源:Default.aspx.cs

示例6: Create_ShouldCreateUser

        public void Create_ShouldCreateUser()
        {
            //arrange
            var userRepository = new UserRepository(Properties.Resources.ConnectionString);
            User user = TestDataHelper.GenerateUser();
            user.FirstName = "TestUser";

            //act
            userRepository.CreateUser(user);

            //asserts
            var resultUser = userRepository.GetUser(user.Id);
            TestDataHelper.PrintUserInfo(resultUser);
            Assert.IsTrue(TestDataHelper.CompareUsers(user, resultUser));
        }
开发者ID:Bot32,项目名称:MeetGenerator,代码行数:15,代码来源:UserRepositoryTest.cs

示例7: MakeSureAdminIsCreated

	    private void MakeSureAdminIsCreated()
	    {
	        var userRepo = new UserRepository();
	        var adminUser = userRepo.GetUser("admin");
            if(adminUser != null)
                return;

            adminUser = new User()
                            {
                                Username = "admin",
                                EncryptedPassword = EncryptedPassword.Create("qwerty")
                            };

            userRepo.SaveUser(adminUser);

	    }
开发者ID:Tipser,项目名称:tipser.nuget,代码行数:16,代码来源:BasicAuthenticationModule.cs

示例8: AddOneThousandUsers

        public void AddOneThousandUsers()
        {
            UserRepository repository = new UserRepository();

            for (ushort k = 1; k <= 1000; k++)
            {
                User user = new User(k, "user" + k);
                repository.SetUser(user);
            }

            for (ushort k = 1; k <= 1000; k++)
            {
                User result = repository.GetUser(k);
                Assert.IsNotNull(result);
                Assert.AreEqual((ulong)k, result.Id);
                Assert.AreEqual("user" + k, result.Name);
            }
        }
开发者ID:ajlopez,项目名称:AjActivity,代码行数:18,代码来源:UserRepositoryTests.cs

示例9: Trivia

 //
 // GET: /Trivia/
 public ActionResult Trivia()
 {
     Guid userId;
     if (Session["UserID"] == null || !Guid.TryParse(Session["UserID"].ToString(), out userId))
     {
         return RedirectToAction("Index", "Home");
     }
     var userRepository = new UserRepository();
     var gameRepository = new GameRepository();
     var currentUser = userRepository.GetUser(userId);
     var currentGame = gameRepository.CreateGame(userId);
     var viewModel = new TriviaViewModel
     {
         CurrentUser = currentUser,
         CurrentGame = currentGame
     };
     return View(viewModel);
 }
开发者ID:narph,项目名称:seinfeld-trivia,代码行数:20,代码来源:TriviaController.cs

示例10: btnSubmit_Click

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var rep = new UserRepository(new CSBCDbContext());
            User user = rep.GetUser(txtUserName.Text, txtPassword.Text);
            if ((user == null) || (user.UserID == 0))
            {
                lblError.Text = "Invalid user / password";
                lblError.Visible = true;
            }
            else
            {
                Session["UserID"] = user.UserID;
                Session["UserName"] = user.Name;
                Session["UserType"] = user.UserType;
                Session["CompanyID"] = rep.GetById(user.UserID).CompanyID;
                Session["TestMode"] = checkTestMode.Checked;

                var seasonrep = new SeasonRepository(new CSBCDbContext());
                var season = seasonrep.GetCurrentSeason((int)Session["CompanyID"]);
                Session["SeasonID"] = season.SeasonID;
                Response.Redirect("welcome1.aspx");
            }
        }
开发者ID:rsalit,项目名称:CSBC,代码行数:23,代码来源:login.aspx.cs

示例11: GetUser

    public override MembershipUser GetUser(string username, bool userIsOnline)
    {
        UserRepository _user = new UserRepository();

        return _user.GetUser(username);
    }
开发者ID:bclark00,项目名称:klmnscamp,代码行数:6,代码来源:MyMembershipProvider.cs

示例12: GetUserAccess

        private void GetUserAccess()
        {
            var msg = "Invalid use name / password combination";
            var giveAccess = false;
            using (var db = new CSBCDbContext())
            {
                var rep = new UserRepository(db);
                User user = rep.GetUser(txtUserName.Text, txtPassword.Text);
                if (user != null & user.HouseID != 0)
                {
                    if (user.PassWord.ToUpper() == txtPassword.Text.ToUpper())
                    {
                        var repoRole = new RoleRepository(db);
                        var accessTypes = repoRole.GetRoles(user.UserID);
                        Session["User"] = user;
                        if (accessTypes.Any(r => r.ScreenName.ToUpper() == "SCORES"))
                        {

                            giveAccess = true;
                            Session["Editing"] = "All";

                        }
                        else
                        {
                            //check to see if they are AD
                            var divisionId = Convert.ToInt32(ddlDivisions.SelectedValue);
                            giveAccess = CheckAD(divisionId, user);
                            if (!giveAccess)
                            {
                                msg = "Use does not have right to edit scores";
                            }
                        }
                        if (giveAccess)
                        {
                            //btnEdit1.Visible = true;
                            grdSchedule.Columns[9].Visible = true;
                        }
                        Session["UserID"] = user.UserID;
                        Session["UserName"] = user.Name;
                        Session["UserType"] = user.UserType;

                        lblName.Text = user.Name;
                        lblName.Visible = true;
                        btnLogout.Visible = true;
                        loginForm.Visible = false;
                        return;

                    }
                    else
                    {
                        msg = "Incorrect password";
                    }

                }
            }
            labelLoginError.Text = msg;
            labelLoginError.Visible = true;
        }
开发者ID:rsalit,项目名称:CSBC,代码行数:58,代码来源:GameSchedules.aspx.cs

示例13: VerifyUserNameHasConfirmedAccount

        private static Guid VerifyUserNameHasConfirmedAccount(string userName, bool throwException)
        {
            var repo = new UserRepository();

            var user = repo.GetUser(userName);
            if (user == null)
            {
                if (throwException)
                {
                    throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
                                                                        "User {0} does not exist!",
                                                                        new object[] {userName}));
                }
            }

            return user == null || !user.IsConfirmed ? Guid.Empty : user.Id;
        }
开发者ID:vaadim,项目名称:yatdl,代码行数:17,代码来源:WebSecurity.cs

示例14: InitUserProfile

        static string InitUserProfile(string username, string firstname, string lastname, string email, bool createToken)
        {
            var repo = new UserRepository();
            var token = string.Empty;
            var user = repo.GetUser(username);
            if (user != null)
            {
                user.UserProfile.FirstName = firstname;
                user.UserProfile.LastName = lastname;

                //create token for email confirmation
                if (createToken)
                {
                    token = GenerateToken();
                    user.ConfirmationToken = token;
                }
                //otherwise - confirmed
                else
                {
                    user.IsConfirmed = true;
                }

                repo.Update(user);
            }
            return token;
        }
开发者ID:vaadim,项目名称:yatdl,代码行数:26,代码来源:WebSecurity.cs

示例15: HasPerm

 public bool HasPerm(string username, string customperm)
 {
     UserRepository _repository = new UserRepository();
     MembershipUser user = _repository.GetUser(username);
     if (user != null)
     {
         return _repository.HasPerm(int.Parse((user.ProviderUserKey).ToString()), customperm);
     }
     else
     {
         return false;
     }
 }
开发者ID:bclark00,项目名称:klmnscamp,代码行数:13,代码来源:MyRoleProvider.cs


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