protected void btnDelete_Click(object sender, EventArgs e) { if (Page.IsValid) { SubCategoryCollection coll = ProductController.GetAllSubCategory(CategoryId); if (coll.Count > 0) { foreach (SubCategory subCategory in coll) { SubCategory.Delete(subCategory.SubCategoryId); } } Category.Delete(CategoryId); string url = "Categories.aspx?message-success=" + CategoriesStrings.GetText(@"MessageCategoryDeleted"); Response.Redirect(url, true); } }
private void FillDdlSubCategory(Int64 ProductId, Int64 CategoryId) { Int64 selectedSubCategory = Product.FetchByID(ProductId) == null ? 0 : Product.FetchByID(ProductId).SubCategoryId; Query q = new Query(SubCategory.TableSchema).Where(SubCategory.Columns.CategoryId, CategoryId).SelectAll(); SubCategoryCollection subCategoryList = SubCategoryCollection.FetchByQuery(q); int index = 0; ddlSubCategory.Items.Clear(); if (subCategoryList.Count > 0) { foreach (var item in subCategoryList) { ddlSubCategory.Items.Add(new ListItem(item.SubCategoryName, item.SubCategoryId.ToString())); if (selectedSubCategory == item.SubCategoryId) { ddlSubCategory.Items[index].Selected = true; } index++; } } }
public ActionResult CreateSubMenu() { SubCategoryCollection subCategoryCollection = SubCategoryDbModel.GetSubCategoryCollection(); return(View("SubCategory", subCategoryCollection)); }