private void TryLoadBlogCategory() { int id = BlogCategoryId; if (id <= 0) { _editorMode = BlogCategoryEditorMode.Creation; _blogCategory = new BXBlogCategory(); } else { _editorMode = BlogCategoryEditorMode.Modification; if ((_blogCategory = BXBlogCategory.GetById(id, BXTextEncoder.EmptyTextEncoder)) == null) { _errorMessage = string.Format(GetMessageRaw("Error.UnableToFindCategory"), id); _editorError = BlogCategoryEditorError.BlogCategoryIsNotFound; return; } } if (!IsPostBack) { BlogCategoryName.Text = _blogCategory.Name; BlogCategorySort.Text = _blogCategory.Sort.ToString(); BlogCategoryXmlId.Text = _blogCategory.XmlId; ListItemCollection siteItems = BlogCategorySites.Items; string[] siteIds = _blogCategory.GetSiteIds(); foreach (string siteId in siteIds) { ListItem li = siteItems.FindByValue(siteId); if (li != null) li.Selected = true; } } else { _blogCategory.Name = BlogCategoryName.Text; if (string.IsNullOrEmpty(BlogCategorySort.Text)) _blogCategory.Sort = 0; else { try { _blogCategory.Sort = Convert.ToInt32(BlogCategorySort.Text); } catch (Exception /*exc*/) { } } _blogCategory.XmlId = BlogCategoryXmlId.Text; List<string> siteIdList = new List<string>(); ListItemCollection siteItems = BlogCategorySites.Items; foreach (ListItem siteItem in siteItems) { if (!siteItem.Selected) continue; siteIdList.Add(siteItem.Value); } _blogCategory.SetSiteIds(siteIdList.ToArray()); } }
public BlogCategoryWrapper(BXBlogCategory charge, BXAdminPage parentPage) { if (charge == null) throw new ArgumentNullException("charge"); if (parentPage == null) throw new ArgumentNullException("parentPage"); _charge = charge; _parentPage = parentPage; }