// // GET: /SubCategoryData/ public ActionResult Details(int subCategoryId = 0) { var subCategoryData = SubCategoryData.GetSubCategoryData(subCategoryId); // ViewBag.SubCategoryName = SubCategoryList.GetSubCategoryInformation(subCategoryId); return(View(subCategoryData)); }
private void listBox4_SelectedIndexChanged(object sender, EventArgs e) { lstBxUcuncuKategori.Items.Clear(); lstBxikinciKategori.Enabled = true; lstBxUcuncuKategori.Enabled = true; lstBxBirinciKategori.Enabled = true; if (lstBxikinciKategori.SelectedItem == null) { } else { var CatId = lstBxikinciKategori.SelectedItem.ToString().Substring(0, 7); SubCategoryData subData = getSubCat(Convert.ToInt32(CatId)).First(); seciliKategori = subData.id.ToString(); if (subData.subCategoryList == null) { lstBxUcuncuKategori.Items.Add("Alt kategori bulunamadı"); lstBxUcuncuKategori.Enabled = false; } else { for (int i = 0; i < subData.subCategoryList.Length; i++) { lstBxUcuncuKategori.Items.Add(subData.subCategoryList[i].id.ToString() + "-" + subData.subCategoryList[i].name); } } } }
public void LoadSubCategoryName() { SubCategoryData subcategorydata = new SubCategoryData(); List <string> subnames = subcategorydata.GetSubName(cbbHCategory.Text); foreach (var subname in subnames) { cbbLCategory.Items.Add(subname); } }
public ActionResult Details(int Id = 0) { if (Id == 0) { RedirectToAction("Index"); } var data = SubCategoryData.GetSubCategoryData(Id); return(View(data)); }
public void SaveCategories(CategoryEditViewModel categoryEdit) { foreach (CategoryViewModel category in categoryEdit.Categories) { if (category.Id == 0) { //Add new Category CategoryData newCategory = new CategoryData() { IsMainMenu = category.IsMainMenu, Name = category.Name, Order = category.Order, Url = category.Url }; category.Id = _categoryRepository.AddCategory(newCategory); } else { //Update Category CategoryData changeCategory = new CategoryData() { Id = category.Id, IsMainMenu = category.IsMainMenu, Name = category.Name, Order = category.Order, Url = category.Url }; _categoryRepository.SaveCategory(changeCategory); } foreach (SubCategoryViewModel subCategory in category.SubCategories) { if (subCategory.Id == 0) { //Add new SubCategory SubCategoryData newSubCategory = new SubCategoryData() { CategoryId = category.Id, Name = subCategory.Name, Order = subCategory.Order, Url = subCategory.Url }; subCategory.Id = _categoryRepository.AddSubCategory(newSubCategory); } else { //Add new SubCategory SubCategoryData changeSubCategory = new SubCategoryData() { Id = subCategory.Id, CategoryId = category.Id, Name = subCategory.Name, Order = subCategory.Order, Url = subCategory.Url }; _categoryRepository.SaveSubCategory(changeSubCategory); } } } List <int> deleteSubCategoryIds = categoryEdit.Categories.SelectMany(x => x.SubCategories.Select(y => y.Id)).Distinct().ToList(); _categoryRepository.DeleteSubCategoriesWhereNotInLIst(deleteSubCategoryIds); List <int> deleteCategoryIds = categoryEdit.Categories.Select(x => x.Id).Distinct().ToList(); _categoryRepository.DeleteCategoriesWhereNotInLIst(deleteCategoryIds); }