private void RemoveCategoryAndReorderSiblings(Category category, IList<Category> categories) { categories.Remove(category); for (int i = 0; i < categories.Count; i++) { categories[i].SetPosition(i); } }
public string CreateCategoryUrl(Category c) { Section sectionTo = this.Section.Connections.Count > 0 ? this.Section.Connections["SetCategory"] as Section : null; if (sectionTo != null) { return UrlHelper.GetUrlFromSection(sectionTo) + "/SetCategory?c=" + HttpContext.Current.Server.UrlEncode(c.Name); } else { return null; } }
public void DeleteCategory(Category category) { if (category.ChildCategories.Count > 0) { throw new ArgumentException("CategoryHasChildCategoriesException"); } if (category.ContentItems.Count > 0) { throw new ArgumentException("CategoryHasContentItemsException"); } this._commonDao.DeleteObject(category); this._commonDao.Flush(); if (category.ParentCategory != null) { RemoveCategoryAndReorderSiblings(category, category.ParentCategory.ChildCategories); } else { RemoveCategoryAndReorderSiblings(category, category.Site.RootCategories); } }
public virtual void SetParentCategory(Category newParentCategory) { if (this._id != -1 && newParentCategory == this._parentCategory) { return; // don't do anything when the parent stays the same. } if (this._parentCategory != null) { IList<Category> categoryList = this._parentCategory.ChildCategories; categoryList.Remove(this); // Re-organize sibling positions. for (int i = 0; i < categoryList.Count; i++) { categoryList[i].SetPosition(i); } } else if (this.Site.RootCategories.Contains(this)) { this.Site.RootCategories.Remove(this); // Re-organize sibling positions. for (int i = 0; i < this.Site.RootCategories.Count; i++) { this.Site.RootCategories[i].SetPosition(i); } } this._parentCategory = newParentCategory; if (newParentCategory != null) { SetPosition(newParentCategory.ChildCategories.Count); newParentCategory.ChildCategories.Add(this); } else { SetPosition(this.Site.RootCategories.Count); this.Site.RootCategories.Add(this); } }
private void WriteCategoryRoot(Category cat, HtmlGenericControl container) { }
private HtmlGenericControl CreateRootCategoryDiv(Category category) { HtmlGenericControl div = new HtmlGenericControl("div"); div.Attributes.Add("class", "rootcategorynode"); HyperLink hpl = new HyperLink(); hpl.Text = category.Name; hpl.NavigateUrl = this.categoryModule.CreateCategoryUrl(category); div.Controls.Add(hpl); return div; }
private HtmlGenericControl CreateCategoryDiv(Category category) { HtmlGenericControl div = new HtmlGenericControl("div"); div.Attributes.Add("id", string.Concat("category", category.Path)); div.Attributes.Add("class", "categorynode"); div.Style.Add("padding-left", string.Format("{0}px", (category.Level * 2))); //div.Style.Add("padding-left", string.Format("{0}px", (category.Level * this.IndentationFactor))); HtmlGenericControl span = new HtmlGenericControl("span"); span.InnerHtml = "<sup>L</sup> <sup>.</sup> "; div.Controls.Add(span); CheckBox chkBox = new CheckBox(); //chkBox.Visible = this.UseCheckBoxes; div.Controls.Add(chkBox); HyperLink hpl = new HyperLink(); hpl.Text = category.Name; hpl.ToolTip = category.Description; hpl.NavigateUrl = this.categoryModule.CreateCategoryUrl(category); div.Controls.Add(hpl); return div; }
public void CreateCategory(Category category) { this._commonDao.SaveObject(category); }
public void UpdateCategory(Category category) { this._commonDao.UpdateObject(category); }
private void SetupParentCategoriesViewData(Category currentCategory) { IList<Category> parentCategories = this._categoryService.GetAllCategories(CuyahogaContext.CurrentSite).ToList(); if (currentCategory != null) { // Remove current category from available parent categories parentCategories.Remove(currentCategory); } ViewData["ParentCategories"] = parentCategories; }
protected void BtnSaveClick(object sender, EventArgs e) { int existing = _categoryService.GetAllCategories(ActiveSite).Where(cat => cat.Name == txtName.Text).Count(); if (existing < 1) { Exception exception = null; try { string path = txtPath.Text; if (CategoryId < 1) _category = new Category(); else _category = _categoryService.GetById(CategoryId); if (ParentCategoryId != -1) //not is root category { _category.ParentCategory = _categoryService.GetById(ParentCategoryId); } _category.Site = ActiveSite; _category.Description = txtDescription.Text; _category.Name = txtName.Text; _category.Path = path; _category.Position = _categoryService.GetPositionFromPath(path); if (_category.Id < 0) { _categoryService.CreateCategory(_category); } else { _categoryService.UpdateCategory(_category); } } catch (Exception ex) { exception = ex; ShowError("Could not save category. Details:<br />" + ex.ToString()); } if (exception == null) Response.Redirect("~/Admin/Categories.aspx?SiteId=" + ActiveSite.Id.ToString()); } else { ShowError("A category of that name already exists. Categories must be uniquely named."); } }
protected void EditCategory() { _category = _categoryService.GetById(CategoryId); BindCategory(); }