示例#1
0
        public void RegisterMemberWithoutDisplayName()
        {
            // Generate a random email address
            userName      = Guid.NewGuid().ToString().Replace("-", "_");
            emailAddress += userName + "@test.com";

            try
            {
                var member = new MemberVm()
                {
                    Email    = emailAddress,
                    Password = "******",
                    Username = userName
                };

                var dbMember = MemberSvc.CreateWithApplication(Manager.Id, member);

                _member        = dbMember.Member;
                _memberOptions = dbMember.Options;
                _memberLogin   = dbMember.Login;

                Assert.AreEqual(MemberManagerMessages.Error.MEMBER_DISPLAY_NAME_REQUIRED, dbMember.Message);
            }
            catch (Exception e)
            {
                Assert.AreEqual(MemberManagerMessages.Error.MEMBER_DISPLAY_NAME_REQUIRED, e.Message);
            }
        }
示例#2
0
        public void RegisterMember()
        {
            // Generate a random email address
            userName      = Guid.NewGuid().ToString().Replace("-", "_");
            emailAddress += userName + "@test.com";

            var member = new MemberVm()
            {
                Email       = emailAddress,
                Password    = "******",
                DisplayName = "Sam Sample",
                Username    = userName
            };

            var dbMember = MemberSvc.CreateWithApplication(Manager.Id, member);

            _member        = dbMember.Member;
            _memberOptions = dbMember.Options;
            _memberLogin   = dbMember.Login;

            Assert.AreNotEqual(_member.Id, 0);
        }
示例#3
0
        /// <summary>
        /// Create a new member under specific application.
        /// </summary>
        /// <param name="id">Application Id</param>
        /// <param name="view">Member view</param>
        /// <returns><![CDATA[ (MemberVm Member, MemberOptionsVm Options, MemberLoginVm Login) ]]></returns>
        public (MemberVm Member, MemberOptionsVm Options, MemberLoginVm Login, bool IsSuccess, string Message) CreateWithApplication(int id, MemberVm view)
        {
            string errorMessage = String.Empty;

            var results = CheckRestrictions(id, view, out errorMessage);

            if (!results.Allow)
            {
                return(null, null, null, false, errorMessage);
            }

            // Create the member
            var dbMember = view.ToEntityCreate();

            dbMember = DataAccess.Member.Create(dbMember);

            // Create the Options for the member based on the application.
            var dbMemberOptions = results.Options.ToEntityCreate(view.ToEntityCreate().Id);

            dbMemberOptions.Member = dbMember;
            dbMemberOptions        = DataAccess.MemberOption.Create(dbMemberOptions);

            // Create Member Login for SSO
            var dbMemberLogin = new MemberLoginVm().ToEntityCreate(view.ToEntityCreate().Id, id);

            dbMemberLogin.Member = dbMember;
            dbMemberLogin        = DataAccess.MemberLogin.Create(dbMemberLogin);

            // Save all transactions.
            DataAccess.Save();

            var member  = new MemberVm(dbMember);
            var options = new MemberOptionsVm(dbMemberOptions);
            var login   = new MemberLoginVm(dbMemberLogin);

            return(member, options, login, true, MemberManagerMessages.Success.MEMBER_CREATE);
        }