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


C# UserRepository.Save方法代码示例

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


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

示例1: ReturnsTrueIfEmailExistsForDifferentUser

 public void ReturnsTrueIfEmailExistsForDifferentUser()
 {
     var repository = new UserRepository(null, SessionSource.CreateSession());
     var user = new User { Name = "test", Credentials = new Credentials("[email protected]", "pass") };
     repository.Save(new User {Name = "test", Credentials = new Credentials("[email protected]", "pass")});
     Assert.True(repository.EmailExists(user));
 }
开发者ID:okeulder,项目名称:codebettercanvas,代码行数:7,代码来源:EmailExistsTests.cs

示例2: ChangePassword

        public ActionResult ChangePassword(StudentChangePasswordVM model)
        {
            if (!ModelState.IsValid)
            {
                return View();
            }

            if (model.NewPassword != model.NewPasswordRepeat)
            {
                ModelState.AddModelError("Error", "New password dont match");
                return View(model);
            }

            UserRepository<Student> stuRepo = new UserRepository<Student>();
            Student student = stuRepo.GetByID(model.StudentID);
            Passphrase hash = PasswordHasher.Hash(model.OldPassword);

            if (PasswordHasher.Equals(model.OldPassword, student.Salt, student.Hash))
            {
                Passphrase hash2 = PasswordHasher.Hash(model.NewPassword);

                student.Salt = hash2.Salt;
                student.Hash = hash2.Hash;

                stuRepo.Save(student);
            }
            else
            {
                ModelState.AddModelError("Error", "Old password dont match");
                return View(model);
            }

            return RedirectToAction("Index", "Student");
        }
开发者ID:hristo-enchev,项目名称:UniversitySystem,代码行数:34,代码来源:StudentController.cs

示例3: Index

        public ViewResult Index(string Name, string Email, string Password)
        {
            try
            {
                UserRepository userRep = new UserRepository();
                Expression<Func<t_user, bool>> filter =
                x => (x.mail == Email && Email != null);
                List<t_user> users = userRep.Get(filter).ToList();
                LoginModel model = new LoginModel();

                if (users.Count > 0)
                {
                    return View(model);
                }
                else
                {
                    t_user newUser = new t_user();
                    newUser.name = Name;
                    newUser.mail = Email;
                    newUser.password = Password;
                    newUser.roleID = 2;
                    userRep.Save(newUser);

                    model.Name = Name;
                    model.Email = Email;
                    model.Password = Password;
                }

                return View(model);
            }
            catch (Exception)
            {
                return null;
            }
        }
开发者ID:lxsndr33,项目名称:Auction,代码行数:35,代码来源:UserController.cs

示例4: AddUser_should_save

        public void AddUser_should_save()
        {
            string username = "save" + Guid.NewGuid();

            var user = new User
            {
                 Email = "[email protected]",
                 FirstName = "john",
                 IsActive = true,
                 LastName = "haigh",
                 PasswordHash = "asdf",
                 Username = username
            };

            var svc = new UserService();
            svc.AddUser(user);

            var repo = new UserRepository();

            var repoUser = repo.Find(u => u.Username == username).FirstOrDefault();

            // Test
            repoUser.ShouldNotBeNull();

            // Cleanup user
            repo.Delete(repoUser);
            repo.Save();

            var results2 = repo.Find(u => u.Username == username);
            var userFound2 = results2.FirstOrDefault();

            Assert.IsNull(userFound2, "Tried to get user but the user was found");
        }
开发者ID:versosystems,项目名称:account-lib,代码行数:33,代码来源:UserServiceTests.cs

示例5: UserExample

        public void UserExample()
        {
            var interests = new HashSet<string> { "distributed systems", "Erlang" };
            var joe = new User("Joe", "Armstrong", interests);

            var entityManager = new EntityManager(client);
            entityManager.Add(joe);
            var repo = new UserRepository(client);
            repo.Save(joe);

            joe.VisitPage();

            joe.AddInterest("riak");

            repo.UpgradeAccount(joe);

            var joeFetched = repo.Get(joe.ID);

            Assert.GreaterOrEqual(joe.PageVisits, 0);
            Assert.Contains("riak", joeFetched.Interests.ToArray());

            PrintObject(joeFetched);

            repo.DowngradeAccount(joe);

            joeFetched = repo.Get(joe.ID);
            PrintObject(joeFetched);
        }
开发者ID:josephjeganathan,项目名称:riak-dotnet-client,代码行数:28,代码来源:DataTypes.cs

示例6: ReturnsFalseIfEmailBelongsToUser

        public void ReturnsFalseIfEmailBelongsToUser()
        {
            var repository = new UserRepository(null, SessionSource.CreateSession());
            var user = new User { Name = "test", Credentials = new Credentials("[email protected]", "pass") };

            repository.Save(user);
            Assert.False(repository.EmailExists(user));
        }
开发者ID:okeulder,项目名称:codebettercanvas,代码行数:8,代码来源:EmailExistsTests.cs

示例7: Find_By_Guid

        public void Find_By_Guid()
        {
            IUserRepository userRepository = new UserRepository(this.Client, this.Database);

            User accountUser = new User("name",  Guid.NewGuid().ToString(), "password");
            userRepository.Save(accountUser);

            User accountUserLoaded = userRepository.Find(accountUser.Guid);
            Assert.IsTrue(accountUserLoaded.Id == accountUserLoaded.Id);
        }
开发者ID:Appacts,项目名称:mobile-analytics-server,代码行数:10,代码来源:UserRepositoryIntegration.cs

示例8: Find_By_Email_And_Password

        public void Find_By_Email_And_Password()
        {
            IUserRepository userRepository = new UserRepository(this.Client, this.Database);

            User accountUser = new User("name", Guid.NewGuid().ToString(), "password");
            userRepository.Save(accountUser);

            User accountUserFound = userRepository.Find(accountUser.Email, accountUser.Password);
            Assert.IsNotNull(accountUserFound);
        }
开发者ID:Appacts,项目名称:mobile-analytics-server,代码行数:10,代码来源:UserRepositoryIntegration.cs

示例9: GivenAUserRepository_WhenIAskForUsers_UsersAreReturned

        public void GivenAUserRepository_WhenIAskForUsers_UsersAreReturned()
        {
            var ctx = new BaillieGiffordEntities();
            var repo = new UserRepository(ctx);
            repo.Create(new User { EMail = "foo.com", Name = "bar" });
            repo.Create(new User { EMail = "foo.com", Name = "bar" });
            repo.Save();
            var users = repo.Entities.ToList();

            users.Count.Should().Be(2);
        }
开发者ID:kevinrjones,项目名称:MVC20130916,代码行数:11,代码来源:GetUserTests.cs

示例10: ReturnsDeveloperIfCredentialsAreValid

        public void ReturnsDeveloperIfCredentialsAreValid()
        {
            var encryptor = Dynamic<IEncryptor>();
            var repository = new UserRepository(encryptor, SessionSource.CreateSession());

            encryptor.Stub(e => e.IsMatch(null, null)).IgnoreArguments().Return(true);

            ReplayAll();
            repository.Save(new User { Name = "#18", Credentials = new Credentials { Email = "[email protected]", Password = "hashed" } });
            var user = repository.FindByCredentials(new Credentials("[email protected]", "marron"));
            Assert.Equal("#18", user.Name);
        }
开发者ID:okeulder,项目名称:codebettercanvas,代码行数:12,代码来源:FindByCredentialsTest.cs

示例11: ReturnsNullIfPasswordsDontMatch

        public void ReturnsNullIfPasswordsDontMatch()
        {
            var encryptor = Dynamic<IEncryptor>();
            var repository = new UserRepository(encryptor, SessionSource.CreateSession());

            encryptor.Expect(e => e.IsMatch("marron", "hashed")).Return(false);

            ReplayAll();
            repository.Save(new User { Name = "#18", Credentials = new Credentials { Email = "[email protected]", Password = "hashed" } });
            Assert.Null(repository.FindByCredentials(new Credentials("[email protected]", "marron")));
            encryptor.VerifyAllExpectations();
        }
开发者ID:okeulder,项目名称:codebettercanvas,代码行数:12,代码来源:FindByCredentialsTest.cs

示例12: Find_By_ForgotPassword

        public void Find_By_ForgotPassword()
        {
            IUserRepository userRepository = new UserRepository(this.Client, this.Database);

            User accountUser = new User("name", Guid.NewGuid().ToString(), "password");
            userRepository.Save(accountUser);

            accountUser.ForgotPasswordGuid = Guid.NewGuid();
            userRepository.Update(accountUser);

            User userFound = userRepository.FindByForgotPassword(accountUser.ForgotPasswordGuid);
            Assert.IsNotNull(userFound);
        }
开发者ID:Appacts,项目名称:mobile-analytics-server,代码行数:13,代码来源:UserRepositoryIntegration.cs

示例13: should_save_new_registration_with_assigned_id

        public void should_save_new_registration_with_assigned_id()
        {
            var User = new domain.Users.User
                           {
                               CreationDate = DateTime.Now,
                               Email = "[email protected]",
                               Password = "Hello",
                               UserName = "Jude"
                           };

            var userRepository = new UserRepository(sessionFactory);
            userRepository.Save(User);
            User.Id.Should().NotBe(Guid.Empty);
        }
开发者ID:judemifsud,项目名称:BookAssignments,代码行数:14,代码来源:UserRepositorySpec.cs

示例14: RegisterUser

        public UserModel RegisterUser(UserModel model, string password)
        {
            var userRepository = new UserRepository();
            var salt = BCryptHelper.GenerateSalt();
            var passwordHash = BCryptHelper.HashPassword(password, salt);

            model.Salt = salt;
            model.Password = passwordHash;

            userRepository.Save(model);
            userRepository.Commit();

            return model;
        }
开发者ID:SokolovAlex,项目名称:private_chat_net,代码行数:14,代码来源:AuthServise.cs

示例15: Save

        public void Save()
        {
            IUserRepository iUserRepository = new UserRepository(this.connectionString);

            User user = new User
                (
                    18,
                    AppActs.DomainModel.Enum.SexType.Male,
                    Guid.NewGuid(),
                    DateTime.Now
                );

            iUserRepository.Save(this.Application.Id, this.Device.Id, user);
        }
开发者ID:Appacts,项目名称:mobile-analytics-server,代码行数:14,代码来源:UserRepositoryIntegration.cs


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