本文整理汇总了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;
}