public async Task <ActionResult> CreateSubMenu(string id) { var dbResult = await Bll.DB_Menu().ListMainMenuAsync(); if (!String.IsNullOrEmpty(dbResult.exceptionMessage)) { return(HttpNotFound()); } else { var result = new SubMenuCreateModel(); foreach (var item in dbResult.resultItem.Where(x => x.Nested == "0").ToList()) { result.mainMenu.Add(new MenuViewModel { Id = item.Id, Name = item.Name }); } return(View(result)); } }
public async Task <ActionResult> CreateSubMenu(string id, MenuViewModel model) { if (ModelState.IsValid) { var dbModel = await Bll.DB_Menu().Add(new DataAccessLayer.AdoModel.Menu { Id = Guid.NewGuid().ToString(), Action = model.Action, Controller = model.Controller, Icon = model.Icon, Name = model.Name, Nested = model.Nested, Rank = model.Rank }); if (dbModel.success) { //this.ClearCache(); return(RedirectToAction("Index")); } } ModelState.AddModelError("", "Yeni Alt Menü Oluşturulamadı!"); var dbResult = await Bll.DB_Menu().ListMainMenuAsync(); var result = new SubMenuCreateModel(); foreach (var item in dbResult.resultItem.Where(x => x.Nested == "0").ToList()) { result.mainMenu.Add(new MenuViewModel { Id = item.Id, Name = item.Name }); } return(View(result)); }