本文整理汇总了C#中Member.CreateContent方法的典型用法代码示例。如果您正苦于以下问题:C# Member.CreateContent方法的具体用法?C# Member.CreateContent怎么用?C# Member.CreateContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Member
的用法示例。
在下文中一共展示了Member.CreateContent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeNew
/// <summary>
/// Creates a new member
/// </summary>
/// <param name="Name">Membername</param>
/// <param name="mbt">Member type</param>
/// <param name="u">The umbraco usercontext</param>
/// <param name="Email">The email of the user</param>
/// <returns>The new member</returns>
public static Member MakeNew(string Name, string LoginName, string Email, MemberType mbt, User u)
{
if (mbt == null) throw new ArgumentNullException("mbt");
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 != "" && GetMemberFromEmail(Email) != null && Membership.Providers[UmbracoMemberProviderName].RequiresUniqueEmail)
throw new Exception(string.Format("Duplicate Email! A member with the e-mail {0} already exists", Email));
else if (GetMemberFromLoginName(loginName) != null)
throw new Exception(string.Format("Duplicate User name! A member with the user name {0} already exists", loginName));
// Lowercased to prevent duplicates
Email = Email.ToLower();
var newId = Guid.NewGuid();
//create the cms node first
var newNode = MakeNew(-1, _objectType, u.Id, 1, Name, newId);
//we need to create an empty member and set the underlying text property
var 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
var m = new Member(newId);
var e = new NewEventArgs();
m.OnNew(e);
m.Save();
return m;
}