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


C# UserService.Create方法代码示例

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


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

示例1: CreateDatabaseWithTestData

		private void CreateDatabaseWithTestData()
		{
			mDatabaseConnection = Effort.DbConnectionFactory.CreateTransient();

			var tempService = new UserService(new TestAuctioneerDbContext(mDatabaseConnection), A.Fake<IUserNotifier>());

			tempService.Create(new TestUser { Id = "1", Email = "[email protected]" }, "Password");
			tempService.Create(new TestUser { Id = "2", Email = "[email protected]" }, "Password");
			tempService.Create(new TestUser { Id = "3", Email = "[email protected]" }, "Password");
			tempService.Create(new TestUser { Id = "4", Email = "[email protected]" }, "Password");
		}
开发者ID:Strachu,项目名称:Auctioneer,代码行数:11,代码来源:UserServiceTests.cs

示例2: Initialize

        public static void Initialize()
        {
            var dbName = ConfigurationManager.AppSettings["dbName"];
            var database = new MongoClient().GetServer().GetDatabase(dbName);

            // Users
            var users = new UserService(database);

            if (!users.Read().Any(u => u.email == "[email protected]"))
            {
                users.Create(new User
                {
                    email = "[email protected]",
                    name = "Authenticated User"
                }, "correct");
            }

            // Jobs
            var jobs = new JobService(database);

            if (!jobs.Read().Any())
            {
                jobs.Create(new Job
                {
                    name = "Honeybadger",
                    description = "It is primarily a carnivorous species and has few natural predators because of its thick skin and ferocious defensive abilities.",
                    words = 365
                });
            }
        }
开发者ID:Myslik,项目名称:opencat,代码行数:30,代码来源:DataConfig.cs

示例3: UserCreateTest

        public void UserCreateTest()
        {
            var service = new UserService();

            const string userName = "test user";
            const string password = "qwerty";

            service.Create(userName, password);
            var user = service.FindByNameAndPassword(userName, password);
            Assert.IsNotNull(user);
            Assert.AreEqual(userName, user.Name);
        }
开发者ID:pxavolkov,项目名称:memo,代码行数:12,代码来源:UserServiceTests.cs

示例4: WhenCreatingUser_ThenReturnsUpdatedUserWithUserId

        public void WhenCreatingUser_ThenReturnsUpdatedUserWithUserId()
        {
            var userRepositoryMock = new Mock<IUserRepository>();

            userRepositoryMock.Setup(u => u.Add(It.IsAny<User>())).Callback<User>(user => user.UserId = 12);

            var services = new UserService(userRepositoryMock.Object, new Mock<IUnitOfWork>().Object);

            var servicesUser = new User { DisplayName = "test", Password = "password" };
            Assert.Equal(0, servicesUser.UserId);

            User createdUser = services.Create(servicesUser);

            Assert.Equal(12, createdUser.UserId);
        }
开发者ID:rajbyexample,项目名称:Firebrick-CMS,代码行数:15,代码来源:UserServiceFixture.cs

示例5: Authenticate

        /// <summary>
        /// Authenticates the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="username">The username.</param>
        /// <param name="returnUrl">The return URL.</param>
        /// <returns></returns>
        public override Boolean Authenticate( HttpRequest request, out string username, out string returnUrl )
        {
            var fbClient = new FacebookClient();
            FacebookOAuthResult oAuthResult;

            if ( fbClient.TryParseOAuthCallbackUrl( request.Url, out oAuthResult ) && oAuthResult.IsSuccess )
            {
                try
                {
                    var redirectUri = new Uri( GetRedirectUrl( request ) );

                    dynamic parameters = new ExpandoObject();
                    parameters.client_id = AttributeValue( "AppID" );
                    parameters.client_secret = AttributeValue( "AppSecret" );
                    parameters.redirect_uri = redirectUri.AbsoluteUri;
                    parameters.code = oAuthResult.Code;

                    dynamic result = fbClient.Post( "oauth/access_token", parameters );

                    string accessToken = result.access_token;

                    fbClient = new FacebookClient( accessToken );
                    dynamic me = fbClient.Get( "me" );
                    string facebookId = "FACEBOOK_" + me.id.ToString();

                    // query for matching id in the user table
                    UserService userService = new UserService();
                    var user = userService.GetByUserName( facebookId );

                    // if not user was found see if we can find a match in the person table
                    if ( user == null )
                    {
                        try
                        {
                            // determine if we can find a match and if so add an user login record

                            // get properties from Facebook dynamic object
                            string lastName = me.last_name.ToString();
                            string firstName = me.first_name.ToString();
                            string email = me.email.ToString();

                            var personService = new PersonService();
                            var person = personService.Queryable().FirstOrDefault( u => u.LastName == lastName && ( u.GivenName == firstName || u.NickName == firstName ) && u.Email == email );

                            if ( person != null )
                            {
                                // since we have the data enter the birthday from Facebook to the db if we don't have it yet
                                DateTime birthdate = Convert.ToDateTime( me.birthday.ToString() );

                                if ( person.BirthDay == null )
                                {
                                    person.BirthDate = birthdate;
                                    personService.Save( person, person.Id );
                                }

                            }
                            else
                            {

                                var dvService = new DefinedValueService();

                                person = new Person();
                                person.IsSystem = false;
                                person.RecordTypeValueId = dvService.GetIdByGuid( SystemGuid.DefinedValue.PERSON_RECORD_TYPE_PERSON );
                                person.RecordStatusValueId = dvService.GetIdByGuid( SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE );

                                person.GivenName = me.first_name.ToString();
                                person.LastName = me.last_name.ToString();
                                person.Email = me.email.ToString();

                                if ( me.gender.ToString() == "male" )
                                    person.Gender = Gender.Male;
                                else if ( me.gender.ToString() == "female" )
                                    person.Gender = Gender.Female;
                                else
                                    person.Gender = Gender.Unknown;

                                person.BirthDate = Convert.ToDateTime( me.birthday.ToString() );
                                person.DoNotEmail = false;

                                personService.Add( person, null );
                                personService.Save( person, null );
                            }

                            user = userService.Create( person, AuthenticationServiceType.External, this.GetType().FullName, facebookId, "fb", true, person.Id );
                        }
                        catch ( Exception ex )
                        {
                            string msg = ex.Message;
                            // TODO: probably should report something...
                        }

                        // TODO: Show label indicating inability to find user corresponding to facebook id
//.........这里部分代码省略.........
开发者ID:jh2mhs8,项目名称:Rock-ChMS,代码行数:101,代码来源:Facebook.cs


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