本文整理汇总了C#中Group.SetCategories方法的典型用法代码示例。如果您正苦于以下问题:C# Group.SetCategories方法的具体用法?C# Group.SetCategories怎么用?C# Group.SetCategories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group.SetCategories方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnCreateGroup_Click
//.........这里部分代码省略.........
List<int> lCategoriesIDs = new List<int>();
foreach (ListItem item in lbCategories.Items)
{
if (item.Selected)
{
lCategoriesIDs.Add(Convert.ToInt32(item.Value));
}
}
if (lCategoriesIDs.Count == 0)
{
lblError.Text = Lang.Trans("Please select category.");
return;
}
#endregion
#region Validate Description
if (description.Length == 0)
{
lblError.Text = Lang.Trans("Please enter group description.");
return;
}
#endregion
#region Validate Group Icon
Image image = null;
if (fuGroupImage.PostedFile.FileName.Length == 0)
{
image = Image.FromFile(Server.MapPath("~/Images") + "/defaultgroupicon.jpg");
}
else
{
try
{
image = Image.FromStream
(fuGroupImage.PostedFile.InputStream);
}
catch
{
lblError.Text = Lang.Trans("Invalid image!");
return;
}
}
#endregion
#endregion
if (Group.IsNameUsed(name))
{
StatusPageMessage = Lang.Trans("Group with such name already exists!");
Response.Redirect("~/ShowStatus.aspx");
}
Group group = new Group();
group.JoinTerms = terms;
group.Name = name;
group.Description = description;
if (ddAgeRestriction.SelectedValue != "-1") group.MinAge = Convert.ToInt32(ddAgeRestriction.SelectedValue);
if (CurrentUserSession != null && CurrentUserSession.IsAdmin() || Config.Groups.AutoApproveGroups)
{
group.Approved = true;
}
if (cbAutomaticallyJoin.Checked)
{
group.Autojoin = true;
group.AutojoinCountry = dropCountry.SelectedValue.Trim() != String.Empty ? dropCountry.SelectedValue.Trim() : null;
group.AutojoinRegion = dropRegion.SelectedValue.Trim() != String.Empty ? dropRegion.SelectedValue.Trim() : null;
group.AutojoinCity = dropCity.SelectedValue.Trim() != String.Empty ? dropCity.SelectedValue.Trim() : null;
}
group.AccessLevel = accessLevel;
group.Owner = owner;
if (accessLevel == Group.eAccessLevel.Moderated)
group.JoinQuestion = question;
group.ActiveMembers++;
group.Save();
group.SetCategories(lCategoriesIDs.ToArray());
Group.SaveIcon(group.ID, image);
GroupMember groupMember = new GroupMember(group.ID, CurrentUserSession.Username);
groupMember.Active = true;
groupMember.Type = GroupMember.eType.Admin;
groupMember.Save();
StatusPageMessage = Lang.Trans("Your group has been created successfully!");
Response.Redirect("~/ShowStatus.aspx");
}