當前位置: 首頁>>代碼示例>>C#>>正文


C# Member.OnNew方法代碼示例

本文整理匯總了C#中umbraco.cms.businesslogic.member.Member.OnNew方法的典型用法代碼示例。如果您正苦於以下問題:C# Member.OnNew方法的具體用法?C# Member.OnNew怎麽用?C# Member.OnNew使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在umbraco.cms.businesslogic.member.Member的用法示例。


在下文中一共展示了Member.OnNew方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MakeNew

        public static Member MakeNew(string Name, string LoginName, string Email, MemberType mbt, User u)
        {
            var loginName = (!String.IsNullOrEmpty(LoginName)) ? LoginName : Name;

            if (String.IsNullOrEmpty(loginName))
                throw new ArgumentException("The loginname must be different from an empty string", "loginName");

            // Test for e-mail
            if (Email != "" && Member.GetMemberFromEmail(Email) != null)
                throw new Exception(String.Format("Duplicate Email! A member with the e-mail {0} already exists", Email));
            else if (Member.GetMemberFromLoginName(loginName) != null)
                throw new Exception(String.Format("Duplicate User name! A member with the user name {0} already exists", loginName));

            Guid newId = Guid.NewGuid();

            //create the cms node first
            CMSNode newNode = MakeNew(-1, _objectType, u.Id, 1, Name, newId);

            //we need to create an empty member and set the underlying text property
            Member tmp = new Member(newId, true);
            tmp.SetText(Name);

            //create the content data for the new member
            tmp.CreateContent(mbt);

            // Create member specific data ..
            SqlHelper.ExecuteNonQuery(
                "insert into cmsMember (nodeId,Email,LoginName,Password) values (@id,@email,@loginName,'')",
                SqlHelper.CreateParameter("@id", tmp.Id),
                SqlHelper.CreateParameter("@loginName", loginName),
                SqlHelper.CreateParameter("@email", Email));

            //read the whole object from the db
            Member m = new Member(newId);

            NewEventArgs e = new NewEventArgs();

            m.OnNew(e);

            m.Save();

            return m;
        }
開發者ID:phaniarveti,項目名稱:Experiments,代碼行數:43,代碼來源:Member.cs


注:本文中的umbraco.cms.businesslogic.member.Member.OnNew方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。