예제 #1
0
    private void TrySaveBlogCategory()
    {
        if (_blogCategory == null)
            return;

        try
        {
            _blogCategory.Save();
			_blogCategoryId = _blogCategory.Id;
        }
        catch (Exception exc)
        {
            _errorMessage = exc.Message;
            _editorError = EditorMode == BlogCategoryEditorMode.Creation ? BlogCategoryEditorError.BlogCategoryCreation : BlogCategoryEditorError.BlogCategoryModification; 
        }
    }
예제 #2
0
	protected void OnToolBarButtonClick(object sender, CommandEventArgs e)
	{
		if (e.CommandName == "delete")
		{
			try
			{
                BXBlogCategory blogCategory = BlogCategory;
                if (blogCategory != null)
                    blogCategory.Delete();

				GoBack();
			}
			catch (Exception ex)
			{
                _errorMessage = ex.Message;
                _editorError = BlogCategoryEditorError.BlogCategoryDeleting;
			}
		}
	}
예제 #3
0
    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());
        }
	}