public virtual ActionResult AdvancedCreate(NavBarItemEditAdminViewModel navBarItemEditViewModel) { StoreFront storeFront = CurrentStoreFrontOrThrow; bool nameIsValid = GStoreDb.ValidateNavBarItemName(this, navBarItemEditViewModel.Name, storeFront.StoreFrontId, storeFront.ClientId, null); if (nameIsValid && ModelState.IsValid) { try { NavBarItem navBarItem = GStoreDb.CreateNavBarItem(navBarItemEditViewModel, storeFront, CurrentUserProfileOrThrow); AddUserMessage("Menu Item Created!", "Menu Item '" + navBarItem.Name.ToHtml() + "' [" + navBarItem.NavBarItemId + "] was created successfully for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "]", UserMessageType.Success); if (CurrentStoreFrontOrThrow.Authorization_IsAuthorized(CurrentUserProfileOrThrow, GStoreAction.NavBarItems_View)) { return(RedirectToAction("AdvancedDetails", new { id = navBarItem.NavBarItemId, ReturnToManager = navBarItemEditViewModel.ReturnToManager })); } return(RedirectToAction("AdvancedManager")); } catch (Exception ex) { string errorMessage = "An error occurred while Creating Menu Item '" + navBarItemEditViewModel.Name + "' for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "] \nError: " + ex.GetType().FullName; if (CurrentUserProfileOrThrow.AspNetIdentityUserIsInRoleSystemAdmin()) { errorMessage += " \nException.ToString(): " + ex.ToString(); } AddUserMessage("Error Creating Menu Item!", errorMessage.ToHtmlLines(), UserMessageType.Danger); ModelState.AddModelError("Ajax", errorMessage); } } else { AddUserMessage("Create Menu Item Error", "There was an error with your entry for new menu item '" + navBarItemEditViewModel.Name.ToHtml() + "' for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "]. Please correct it below and save.", UserMessageType.Danger); } navBarItemEditViewModel.FillListsIfEmpty(storeFront.Client, storeFront); navBarItemEditViewModel.IsCreatePage = true; return(View("AdvancedCreate", navBarItemEditViewModel)); }
public ActionResult Create(NavBarItemEditAdminViewModel viewModel) { StoreFront storeFront = CurrentStoreFrontOrThrow; bool nameIsValid = GStoreDb.ValidateNavBarItemName(this, viewModel.Name, storeFront.StoreFrontId, storeFront.ClientId, null); if (nameIsValid && ModelState.IsValid) { try { NavBarItem navBarItem = GStoreDb.CreateNavBarItem(viewModel, storeFront, CurrentUserProfileOrThrow); AddUserMessage("Menu Item Created!", "Menu Item '" + navBarItem.Name.ToHtml() + "' [" + navBarItem.NavBarItemId + "] was created successfully for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "]", UserMessageType.Success); return(RedirectToAction("Manager")); } catch (Exception ex) { string errorMessage = "An error occurred while Creating Menu Item '" + viewModel.Name + "' for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "] \nError: " + ex.GetType().FullName; if (CurrentUserProfileOrThrow.AspNetIdentityUserIsInRoleSystemAdmin()) { errorMessage += " \nException.ToString(): " + ex.ToString(); } AddUserMessage("Error Creating Menu Item!", errorMessage.ToHtmlLines(), UserMessageType.Danger); ModelState.AddModelError("Ajax", errorMessage); } } else { AddUserMessage("Create Menu Item Error", "There was an error with your entry for new menu item '" + viewModel.Name.ToHtml() + "' for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "]. Please correct it below and save.", UserMessageType.Danger); } viewModel.FillListsIfEmpty(storeFront.Client, storeFront); viewModel.UpdateParentNavBarItem(CurrentStoreFrontOrThrow.NavBarItems.SingleOrDefault(nb => nb.NavBarItemId == viewModel.ParentNavBarItemId)); viewModel.IsSimpleCreatePage = true; return(View("Create", viewModel)); }