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


C# UserRepository.Create方法代码示例

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


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

示例1: TestMethod1

        public void TestMethod1()
        {
            var dbContext = new DanwuDbContext();
            var context = new EntityFrameworkRepositoryContext();
            var unitOfWork = new EntityFrameworkUnitOfWork(dbContext);
            IUserRepository userRepository = new UserRepository(context);
            userRepository.Create(new User()
            {
                UserName = "wudan",
                NickName = "坏坏男孩",
                RealName = "吴丹",
                PhoneNum = "18916765826",
                Email = "[email protected]",
                Status = UserStatus.Enabled,
                PassWord = "123456",
                RegisterTime = DateTime.Now,
                LastLogonTime = DateTime.Now
            });
            userRepository.Create(new User()
            {
                UserName = "wudan1",
                NickName = "坏坏男孩1",
                RealName = "吴丹1",
                PhoneNum = "18916765000",
                Email = "[email protected]",
                Status = UserStatus.Disabled,
                PassWord = "123456",
                RegisterTime = DateTime.Now,
                LastLogonTime = DateTime.Now
            });

            var result = context.Commit();
            //var result = unitOfWork.Commit();
        }
开发者ID:wudan330260402,项目名称:Danwu.Core,代码行数:34,代码来源:UnitTest1.cs

示例2: 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

示例3: CreateUser

        public static BaseActionResult CreateUser(User obj4create)
        {
            string msg;
            if (obj4create == null)
            {
                msg = string.Format(XiaoluResources.MSG_CREATE_SUCCESS, XiaoluResources.STR_USER) + string.Format(XiaoluResources.STR_FAIL_RESAON, XiaoluResources.MSG_OBJECT_IS_NULL);
                return new BaseActionResult(false, msg);
            }

            try
            {
                using (var context = new XiaoluEntities())
                {
                    var repository = new UserRepository(context);
                    string newId = Guid.NewGuid().ToString();
                    obj4create.Id = newId;
                    repository.Create(obj4create);
                    context.SaveChanges();
                    msg = string.Format(XiaoluResources.MSG_CREATE_SUCCESS, obj4create.Name);
                    return new BaseActionResult(true, msg);
                }
            }
            catch (Exception e)
            {
                msg = string.Format(XiaoluResources.MSG_CREATE_FAIL, obj4create.Name) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
                return new BaseActionResult(false, msg);
            }
        }
开发者ID:neilchennan,项目名称:Xiaolu,代码行数:28,代码来源:BusinessService.User.cs

示例4: GetCategoryService

		private ICategoryService GetCategoryService(UnitOfWork uow) {
			ICategoryRepository cateRepo = new CategoryRepository(uow);

			IState request = new DummyRequest();

			ILogger logger = new ConsoleLogger();

			IUserRepository userRepo = new UserRepository(uow);
			User user = userRepo.Create(new User {
				Name = "D. Ummy",
				ProviderId = "12345678",
				FullName = "Mr. Doh Ummy",
				EmailAddress = "[email protected]",
				Culture = "th-TH",
				TimeZone = "GMT Standard Time"
			});

			List<IEventSubscriber> subscribers = new List<IEventSubscriber>();

			IEventPublisher eventPublisher = new EventPublisher(subscribers, logger, request);
			IUserProvider userProvider = new DummyUserProvider(user);
			IPermissionService permService = new PermissionService();

			return new CategoryService(userProvider, cateRepo, eventPublisher, logger, permService);
		}
开发者ID:razzles67,项目名称:NForum,代码行数:25,代码来源:SetGetTests.cs

示例5: GetByLogin_LoginExists

        public void GetByLogin_LoginExists()
        {
            var userRepository = new UserRepository(_contextFactory);
            var authenticationRepository = new LoginAuthenticationRepository(_contextFactory);

            var user = new User { Name = "name", Email = "email" };
            var userId = userRepository.Create(user);

            var initalLoginAuth = new LoginAuthentication
            {
                UserId = userId,
                LoginName = "login",
                PasswordHash = Enumerable.Range(0, 32).Select(i => (byte)i).ToArray(),
                Salt = Enumerable.Range(0, 16).Select(i => (byte)i).ToArray()
            };

            authenticationRepository.Save(initalLoginAuth);

            var restoredLoginAuthentication = authenticationRepository.GetByLogin(initalLoginAuth.LoginName);

            Assert.NotNull(restoredLoginAuthentication);
            Assert.AreEqual(initalLoginAuth.UserId, restoredLoginAuthentication.UserId);
            Assert.AreEqual(initalLoginAuth.LoginName, restoredLoginAuthentication.LoginName);
            CollectionAssert.AreEqual(initalLoginAuth.Salt, restoredLoginAuthentication.Salt);
            CollectionAssert.AreEqual(initalLoginAuth.PasswordHash, restoredLoginAuthentication.PasswordHash);
        }
开发者ID:eugene-blokhin,项目名称:EasyRead,代码行数:26,代码来源:LoginAuthenticationRepositoryTests.cs

示例6: GetPostService

		private void GetPostService(UnitOfWork uow, out ICategoryService categoryService, out IForumService forumService, out ITopicService topicService, out IPostService postService) {
			ICategoryRepository cateRepo = new CategoryRepository(uow);
			IForumRepository forumRepo = new ForumRepository(uow);
			ITopicRepository topicRepo = new TopicRepository(uow);
			IPostRepository postRepo = new PostRepository(uow);
			IForumConfigurationRepository configRepo = new ForumConfigurationRepository(uow);

			IState request = new DummyRequest();

			ILogger logger = new ConsoleLogger();

			IUserRepository userRepo = new UserRepository(uow);
			User user = userRepo.Create(new User {
				Name = "D. Ummy",
				ProviderId = "12345678",
				FullName = "Mr. Doh Ummy",
				EmailAddress = "[email protected]",
				Culture = "th-TH",
				TimeZone = "GMT Standard Time"
			});

			List<IEventSubscriber> subscribers = new List<IEventSubscriber>();

			IEventPublisher eventPublisher = new EventPublisher(subscribers, logger, request);
			IUserProvider userProvider = new DummyUserProvider(user);
			IPermissionService permService = new PermissionService();
			IForumConfigurationService confService = new ForumConfigurationService(configRepo);

			categoryService = new CategoryService(userProvider, cateRepo, eventPublisher, logger, permService);
			forumService = new ForumService(userProvider, cateRepo, forumRepo, topicRepo, postRepo, eventPublisher, logger, permService);
			topicService = new TopicService(userProvider, forumRepo, topicRepo, postRepo, eventPublisher, logger, permService, confService);
			postService = new PostService(userProvider, forumRepo, topicRepo, postRepo, eventPublisher, logger, permService, confService);
		}
开发者ID:razzles67,项目名称:NForum,代码行数:33,代码来源:TestCustomPropertiesHolders.cs

示例7: CreateUser_General

        public void CreateUser_General(long id, string name, string email)
        {
            var user = new User {Id = id, Name = name, Email = email};

            var repository = new UserRepository(_contextFactory);

            var userId = repository.Create(user);
            Assert.Greater(userId, 0);
        }
开发者ID:eugene-blokhin,项目名称:EasyRead,代码行数:9,代码来源:UserRepositoryTest.cs

示例8: InitializeFixture

        private void InitializeFixture()
        {
            this.defaultTestUser = new User()
                                       {
                                           AuthorizationId = "TestAuthorizationId",
                                           DisplayName = "DefaultTestUser"
                                       };

            var repository = new UserRepository();
            repository.Create(this.defaultTestUser);
        }
开发者ID:modulexcite,项目名称:reference-application,代码行数:11,代码来源:VehicleRepositoryFixture.cs

示例9: Setup

        public void Setup()
        {
            _transactionScope = new TransactionScope();
            _nickname1 = "nickname1";

            _userRepository = new UserRepository(ConfigurationManager.ConnectionStrings["mblog"].ConnectionString);

            Blog blog1 = BuildMeA
                .Blog("title1", "description1", _nickname1, DateTime.Now);
            Blog blog2 = BuildMeA
                .Blog("title2", "description2", _nickname1, DateTime.Now);

            _user = BuildMeA.User("email1", "name1", "password1")
                .WithBlog(blog1)
                .WithBlog(blog2);

            _userRepository.Create(_user);

            _user2 = BuildMeA.User("email1", "name1", "password1");
            _userRepository.Create(_user2);
        }
开发者ID:kevinrjones,项目名称:mblog,代码行数:21,代码来源:UserRepositoryTest.cs

示例10: GetById_UserExists

        public void GetById_UserExists()
        {
            var repository = new UserRepository(_contextFactory);

            var savedUser = new User { Name = "name", Email = "email" };
            var userId = repository.Create(savedUser);
            var retrievedUser = repository.GetById(userId);

            Assert.IsNotNull(retrievedUser);
            Assert.AreEqual(userId, retrievedUser.Id);
            Assert.AreEqual(savedUser.Name, retrievedUser.Name);
            Assert.AreEqual(savedUser.Email, retrievedUser.Email);
        }
开发者ID:eugene-blokhin,项目名称:EasyRead,代码行数:13,代码来源:UserRepositoryTest.cs

示例11: WhenRequestingAvailableUserByAuthenticatedId_ThenReturnsUserFromRepository

        public void WhenRequestingAvailableUserByAuthenticatedId_ThenReturnsUserFromRepository()
        {
            var userData = new User
                                {
                                    AuthorizationId = "TestId",
                                    DisplayName = "TestDisplayName",
                                };

            var userRepository = new UserRepository();
            userRepository.Create(userData);

            var retrievedUser = userRepository.GetByAuthenticatedId(userData.AuthorizationId);

            Assert.NotNull(retrievedUser);
        }
开发者ID:modulexcite,项目名称:reference-application,代码行数:15,代码来源:UserRepositoryFixture.cs

示例12: WhenAddingUser_ThenUserPersists

        public void WhenAddingUser_ThenUserPersists()
        {
            var userRepository = new UserRepository();

            var newUser = new User
                              {
                                  AuthorizationId = "AnAuthorizationId",
                                  DisplayName = "TheDisplayName",
                              };

            userRepository.Create(newUser);

            Assert.NotNull(userRepository.Set
                .Where(u => u.AuthorizationId == newUser.AuthorizationId).First());
        }
开发者ID:modulexcite,项目名称:reference-application,代码行数:15,代码来源:UserRepositoryFixture.cs

示例13: UserRepository

        public void GivenAliceWantsToReadCharliesWallAndCharlieHasMessagesOnHisWallWhenProcessUserInputIsCalledThenTheProgramDisplaysCharliesWallMessagesAndHowLongHasCharliePostedEachMessage()
        {
            var repository = new UserRepository();
            var broker = new MessageBroker(repository);
            var commandFactory = new CommandFactory(broker);
            var parser = new InputParser(commandFactory);

            var charlie = repository.Create("charlie");
            charlie.Post("message from charlie");

            this.consoleMock.ConsoleRead().Returns("charlie");

            var program = new Program(this.consoleMock, parser, new MessageFormaterFactory());

            program.ProcessUserInput();

            this.consoleMock.Received().ConsoleWrite("message from charlie (0 seconds ago)");
        }
开发者ID:pedromsantos,项目名称:ConsoleTwitter,代码行数:18,代码来源:ProgramTests.cs

示例14: WhenAddingUser_ThenUserReturnsPopulatedNewUser

        public void WhenAddingUser_ThenUserReturnsPopulatedNewUser()
        {
            var userRepository = new UserRepository();

            const string authorizationId = "AnAuthorizationId";
            const string displayName = "TheDisplayName";
            var newUser = new User
                              {
                                  AuthorizationId = authorizationId,
                                  DisplayName = displayName,
                              };

            userRepository.Create(newUser);

            Assert.NotNull(newUser);
            Assert.Equal(authorizationId, newUser.AuthorizationId);
            Assert.Equal(displayName, newUser.DisplayName);
        }
开发者ID:modulexcite,项目名称:reference-application,代码行数:18,代码来源:UserRepositoryFixture.cs

示例15: InitializeFixture

        private void InitializeFixture()
        {
            defaultTestUser = new User()
                                       {
                                           AuthorizationId = "TestAuthorizationId",
                                           DisplayName = "DefaultTestUser"
                                       };

            var userRepository = new UserRepository();
            userRepository.Create(defaultTestUser);

            int userId = defaultTestUser.UserId;

            var vehicleRepository = new VehicleRepository();
            defaultVehicle = new Vehicle()
                                      {
                                          Name = "Test Vehicle"
                                      };
            vehicleRepository.Create(defaultTestUser.UserId, defaultVehicle);
        }
开发者ID:calebjenkins,项目名称:mobile-web,代码行数:20,代码来源:ReminderRepositoryFixture.cs


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