public void Add(CategoryInfo categoryInfo) { if (categoryInfo.ParentCategoryInfo != null) { categoryInfo.ParentCategoryInfo = this.DataSource.CategoryInfos.Find(categoryInfo.ParentCategoryInfo.ID); } this.DataSource.CategoryInfos.Add(categoryInfo); this.DataSource.SaveChanges(); }
public static void CategoryCheckSearch(CategoryInfo category, long selfID) { if (category.ParentCategoryInfo != null) { if (category.ParentCategoryInfo.ID == selfID) { _IsSubflag = true; } else if (category.ParentCategoryInfo.ParentCategoryInfo != null) { CategoryCheckSearch(category.ParentCategoryInfo, selfID); } } }
public CategoryInfo GetEntity() { CategoryInfo category = new CategoryInfo(); category.ID = this.ID; category.CategoryName = this.CategoryName; ICategoryInfoDataProvider dataProvider = new CategoryInfoDataProvider(); CategoryInfo parentCatagory = dataProvider.GetCategoryByID(this.CategorySelectedID); if (parentCatagory != null) { category.ParentCategoryInfo = parentCatagory; } return category; }
public static CategoryModel GetViewModel(CategoryInfo category) { CategoryModel model = new CategoryModel(); model.ID = category.ID; model.CategoryName = category.CategoryName; model.ParentCategoryName = DropDownListHelper.GetParentCategoryName(category); ICategoryInfoDataProvider dataProvider = new CategoryInfoDataProvider(); if (category.BookAndCategorys.Count > 0 ||dataProvider.GetCategoryListByParentID(category.ID).Count() > 0 ) { model.IsUse = true; } return model; }
public static String GetParentCategoryName(CategoryInfo category) { StringBuilder strPathName = new StringBuilder(); if (category.ParentCategoryInfo != null) { strPathName.Append(category.ParentCategoryInfo.CategoryName); InsertParentCategoryName(category.ParentCategoryInfo, strPathName); } return strPathName.ToString(); }
public static void InsertSelectListItem(List<SelectListItem> categorySelectList, CategoryInfo categoryInfo, int subLevel) { string breakStr = string.Empty; for (int i = 0; i < subLevel; i++) { breakStr += UntityContent.DropDwonListPathTemplate; } categorySelectList.Add(new SelectListItem { Text = breakStr + categoryInfo.CategoryName, Value = categoryInfo.ID.ToString() }); }
public static void InsertParentCategoryName(CategoryInfo pcategory, StringBuilder strPathName) { if (pcategory.ParentCategoryInfo != null) { strPathName.Append(UntityContent.CategoryPathTemplate + pcategory.ParentCategoryInfo.CategoryName); InsertParentCategoryName(pcategory.ParentCategoryInfo, strPathName); } }
public void Update(CategoryInfo categoryInfo) { CategoryInfo category = this.GetCategoryByID(categoryInfo.ID); category.CategoryName = categoryInfo.CategoryName; if (categoryInfo.ParentCategoryInfo != null) { category.ParentCategoryInfo = this.DataSource.CategoryInfos.Find(categoryInfo.ParentCategoryInfo.ID); } else { category.ParentCategoryInfo = null; } this.DataSource.SaveChanges(); }
private bool ValidationCategoryIsExist(CategoryInfo categoryInfo) { bool flag = false; IEnumerable<CategoryInfo> categorys = this.ICategoryInfoDataProvider.GetCategoryListByName(categoryInfo.CategoryName); if (categorys.Count() > 0) { if (categorys.Where(c => c.ParentCategoryInfo == categoryInfo.ParentCategoryInfo).Count() > 0) { flag = true; } } return flag; }