예제 #1
0
        public ActionResult SelectMenu(MenuItemModel menuItem)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    MenuItem item = _database.MenuItems.Single(menu => menu.Id == menuItem.Id);


                    Payment payment = _database.Payments.CreateObject();
                    payment.MenuItemId      = item.Id;
                    payment.UserId          = WebSecurity.CurrentUserId;
                    payment.Date            = DateTime.Now;
                    payment.RestaurantID    = item.UserId;
                    payment.ReservationHour = menuItem.ReservationHour;
                    _database.Payments.Attach(payment);
                    _database.ObjectStateManager.ChangeObjectState(payment, EntityState.Added);
                    _database.SaveChanges();
                    return(RedirectToAction("Index", "Payment"));
                }
                return(View(menuItem));
            }
            catch (OptimisticConcurrencyException optimisticConcurrencyException)
            {
                _database.MenuItems.Detach(menuItem);
                ModelState.AddModelError("", "Optimistic Concurrency Exception occurred. Save Again to override");
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "See exception and inner exception");
            }

            return(View(menuItem));
        }
예제 #2
0
        public IActionResult SelectCategory(CategoryViewModel vm)
        {
            CategoryModel            catModel  = new CategoryModel(_db);
            MenuItemModel            menuModel = new MenuItemModel(_db);
            List <MenuItem>          items     = menuModel.GetAllByCategory(vm.CategoryId);
            List <MenuItemViewModel> vms       = new List <MenuItemViewModel>();

            if (items.Count > 0)
            {
                foreach (MenuItem item in items)
                {
                    MenuItemViewModel mvm = new MenuItemViewModel();
                    mvm.Qty          = 0;
                    mvm.CategoryId   = item.CategoryId;
                    mvm.CategoryName = catModel.GetName(item.CategoryId);
                    mvm.Description  = item.Description;
                    mvm.Id           = item.Id;
                    mvm.PRO          = item.Protein;
                    mvm.SALT         = item.Salt;
                    mvm.FAT          = Convert.ToDecimal(item.Fat);
                    mvm.FBR          = item.Fibre;
                    mvm.CHOL         = item.Cholesterol;
                    mvm.CAL          = item.Calories;
                    mvm.CARB         = item.Carbs;
                    vms.Add(mvm);
                }
                MenuItemViewModel[] myMenu = vms.ToArray();
                HttpContext.Session.Set <MenuItemViewModel[]>("menu", myMenu);
            }
            vm.SetCategories(HttpContext.Session.Get <List <Category> >("categories"));
            return(View("Index", vm)); // need the original Index View here
        }
        private void txtName_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox         t      = (TextBox)sender;
            string          filter = t.Text;
            ICollectionView cv     = CollectionViewSource.GetDefaultView(dg.ItemsSource);

            if (filter == "")
            {
                cv.Filter = null;
            }
            else
            {
                cv.Filter = o =>
                {
                    MenuItemModel p = o as MenuItemModel;

                    if (t.Name == "txtId" && IsNumeric(filter))
                    {
                        return(p.item_id == Convert.ToInt32(filter));
                    }
                    if (t.Name == "txtCategoria")
                    {
                        return(p.cat_menu_nombre.ToUpper().StartsWith(filter.ToUpper()));
                    }
                    return(p.item_nombre.ToUpper().StartsWith(filter.ToUpper()));
                };
            }
        }
예제 #4
0
        private void LoadMenu()
        {
            var menu   = new List <MenuItemModel>();
            var orders = new MenuItemModel("Orders")
            {
                Text    = "Orders",
                Command = new RelayCommand(param => OnNavigate(param), null)
            };
            var customers = new MenuItemModel("Customers")
            {
                Text    = "Customers",
                Command = new RelayCommand(param => OnNavigate(param), null)
            };

            var accueil = new MenuItemModel("Accueil")
            {
                Text    = "Accueil",
                Command = new RelayCommand(param => OnNavigate(param), null)
            };

            var company = new MenuItemModel("company")
            {
                Text = "company",
            };

            company.Children.Add(orders);
            company.Children.Add(customers);
            menu.Add(accueil);
            menu.Add(company);
            MenuGenerale = menu;;
        }
예제 #5
0
        public ItemDetail(MenuItemModel item)
        {
            InitializeComponent();
            menuItem = item;
            stackSpecialInst.IsVisible = false;

            cookingPref          = new PreferencesView();
            cookingPref.Title    = "Your Cooking Preference";
            cookingPref.SubTitle = "";
            cookingPref.Items    = new string[] {
                "Oil",
                "Butter",
                "Olive Oil"
            };

            breadPref          = new PreferencesView();
            breadPref.Title    = "Choose your Bread (Required)";
            breadPref.SubTitle = "Select One";
            breadPref.Items    = new string[] {
                "Chapati - 1 piece:",
                "Bread - 3 piece:",
            };
            stackPreferences.Children.Add(cookingPref);
            stackPreferences.Children.Add(breadPref);
        }
예제 #6
0
        public MenuItemModelBuilder AddMenuItem <TController>(IEnumerable <NetzErfassungsmodus> netzErfassungsmoduses, string action = "Index")
        {
            var controllerType = typeof(TController);

            if (permissionService.CheckAccess(controllerType, action) == Access.Denied)
            {
                return(new MenuItemModelBuilder(permissionService, serverConfigurationProvider, netzErfassungsmodus, new List <MenuItemModel>()));
            }

            if (!netzErfassungsmoduses.Contains(netzErfassungsmodus))
            {
                return(new MenuItemModelBuilder(permissionService, serverConfigurationProvider, netzErfassungsmodus, new List <MenuItemModel>()));
            }

            var menuItemModel = new MenuItemModel
            {
                Area       = controllerType.GetAreaName(),
                Controller = controllerType.GetControllerName(),
                Action     = action
            };



            menuItemModel.Text = (serverConfigurationProvider.Environment == ApplicationEnvironment.Development ? ReportTypeService.GetReportType(controllerType, netzErfassungsmodus) : string.Empty) + GetStringFromResource(menuItemModel.ResourceKey);

            menuItemModels.Add(menuItemModel);

            return(new MenuItemModelBuilder(permissionService, serverConfigurationProvider, netzErfassungsmodus, menuItemModel.SubMenuItemModels));
        }
예제 #7
0
 public static MenuItemModel Insert(MenuItemModel menuItem)/*,int menuItem, string itemName,
                                                            * int price,string picture,string description,int menuSectionID)*/
 {
     try
     {
         using (RoundTheCornerEntities rc = new RoundTheCornerEntities())
         {
             PL.TblMenuItem newRow = new TblMenuItem()
             {
                 ItemID        = rc.TblMenuItems.Any() ? rc.TblMenuItems.Max(u => u.ItemID) + 1 : 1,
                 ItemName      = menuItem.ItemName,
                 MenuID        = menuItem.MenuItem,
                 Price         = menuItem.Price,
                 Picture       = menuItem.Picture,
                 Description   = menuItem.Description,
                 MenuSectionID = menuItem.MenuSectionID
             };
             rc.TblMenuItems.Add(newRow);
             rc.SaveChanges();
             menuItem.ItemID = newRow.ItemID;
             return(menuItem);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #8
0
        public MenuIndexModel LoadIndex(long?languageID)
        {
            MenuBusiness     menuBusiness     = new MenuBusiness();
            LanguageBusiness languageBusiness = new LanguageBusiness();

            MenuIndexModel menuIndexModel = new MenuIndexModel();

            long defaultLanguageID = languageBusiness.GetFirstLanguage();

            if (!languageID.HasValue)
            {
                languageID = defaultLanguageID;
            }

            IEnumerable <Language> languageList = languageBusiness.LanguageList();

            menuIndexModel.LanguageList = new SelectList(languageList, "ID", "Name", languageID);

            List <Menu> menu = menuBusiness.GetMenuList();

            List <MenuItemModel> menuItemList = new List <MenuItemModel>();

            foreach (Menu item in menu)
            {
                MenuItemModel tmpItem = new MenuItemModel();

                tmpItem.ID      = item.ID;
                tmpItem.TopMenu = item.TopMenu;

                List <MenuTranslation> _menuTranslation = item.MenuTranslation.ToList();

                if (_menuTranslation != null && _menuTranslation.Count > 0)
                {
                    MenuTranslation menuTranslation = _menuTranslation.FirstOrDefault(z => z.LanguageID == languageID);

                    if (menuTranslation != null)
                    {
                        tmpItem.LanguageID = menuTranslation.LanguageID;
                        tmpItem.Name       = menuTranslation.Name;
                        tmpItem.Sort       = menuTranslation.Sort;
                        tmpItem.URL        = menuTranslation.URL;
                    }
                    else
                    {
                        MenuTranslation defaultMenuTranslation = _menuTranslation.FirstOrDefault(z => z.LanguageID == defaultLanguageID);

                        tmpItem.LanguageID = defaultMenuTranslation.LanguageID;
                        tmpItem.Name       = string.Format("Çeviri eklenmemiş , ({0})", defaultMenuTranslation.Name);
                        tmpItem.Sort       = defaultMenuTranslation.Sort;
                        tmpItem.URL        = defaultMenuTranslation.URL;
                    }
                }

                menuItemList.Add(tmpItem);
            }

            menuIndexModel.MenuList = menuItemList;

            return(menuIndexModel);
        }
예제 #9
0
        private static void AddActionsToMenuItem(MenuItemModel aMenuItem, XmlNode aViewNode, ApplicationXMLModel anApplicationModel)
        {
            //Add current viewNode actions to aMenuItem.Children
            XmlNode viewActionsNode        = aViewNode.SelectSingleNode("ViewActions");
            List <MenuItemModel> childList = new List <MenuItemModel>();

            if (viewActionsNode != null)
            {
                foreach (XmlNode viewActionNode in viewActionsNode.ChildNodes)
                {
                    MenuItemModel menuItem = GetUXActionsFromNode(viewActionNode, anApplicationModel);

                    XmlNode sequenceNode = viewActionNode.SelectSingleNode("Sequence");
                    if (sequenceNode != null && menuItem != null)
                    {
                        menuItem.Sequence = int.Parse(sequenceNode.InnerText);
                        childList.Add(menuItem);
                    }
                }
                childList.Sort();
                aMenuItem.Children.AddRange(childList);
            }
            //check if aViewNode has any children, call self recursively
            XmlNode children = aViewNode.SelectSingleNode("Children");

            if (children != null)
            {
                foreach (XmlNode childViewNode in children)
                {
                    AddActionsToMenuItem(aMenuItem, childViewNode, anApplicationModel);
                }
            }
        }
예제 #10
0
        public ResponseModel LoadMainMenuItemsList(List <UserModel.UserPermission> UserPermissions)
        {
            string        sFunctionName = "LoadMainMenuItemsList(,)";
            ResponseModel Result        = new ResponseModel();
            MenuItemModel MainMenuItem;
            Dictionary <string, string> MenuParent = new Dictionary <string, string>();

            //Clear Main Menu Items List Before Re-Populating it.
            SessionWrapper.MainMenuItemModelList = new List <MenuItemModel>();
            //Set Single Modules in Dictionary
            foreach (UserModel.UserPermission UserPermission in UserPermissions)
            {
                if (!MenuParent.ContainsKey(UserPermission.ModuleID))
                {
                    MenuParent.Add(UserPermission.ModuleID, UserPermission.ModuleFunctionID);
                }
            }
            foreach (UserModel.UserPermission UserPermission in UserPermissions)
            {
                //Only Fetch Single Module. Remove ModuleID so that same module is not fetched again.
                if (MenuParent.ContainsKey(UserPermission.ModuleID))
                {
                    MainMenuItem = new MenuItemModel();
                    Result       = MainMenuItem.getMainMenuItem(UserPermission.ModuleID, UserPermission.ModuleFunctionID);
                    MenuParent.Remove(UserPermission.ModuleID);
                    SessionWrapper.MainMenuItemModelList.Add(MainMenuItem);
                }
            }
            Result.SuccessfullyPassed();
            return(Result);
        }
예제 #11
0
        private static void MoveShowActionToStartAction(string aStartActionIdentity, XmlNode aViewNode, ApplicationXMLModel anApplicationModel)
        {
            XmlNode uXActionIdentityNode = aViewNode.SelectSingleNode("Action/UXAction/Id");

            if (uXActionIdentityNode == null)
            {
                return;
            }

            string uXActionIdentity = uXActionIdentityNode.InnerText;

            MenuItemModel menuItemResult = FindStartItem(aStartActionIdentity, anApplicationModel.MenuItems);

            if (menuItemResult == null)
            {
                return;
            }

            if (ActionsContainsIdentity(menuItemResult.Actions, uXActionIdentity))
            {
                return;
            }

            menuItemResult.Actions.Add(new UXAction {
                Identity = uXActionIdentity, Parent = aStartActionIdentity
            });
        }
예제 #12
0
        public ActionResult Delete(string id)
        {
            var menuItemModel  = new MenuItemModel();
            var deleteMenuItem = menuItemModel.GetSpecificMenuItem(int.Parse(id));

            return(View(deleteMenuItem));
        }
예제 #13
0
        public ActionResult Edit(string id)
        {
            var menuItemModel  = new MenuItemModel();
            var menuItemToEdit = menuItemModel.GetSpecificMenuItem(int.Parse(id));

            return(View(menuItemToEdit));
        }
예제 #14
0
        public ActionResult Index(string SearchItemText, string SearchForMenu, string SearchParentItem)
        {
            var menuItemModel = new MenuItemModel();
            var menuItemList  = menuItemModel.GetListOfMenuItems(true, false, SearchItemText, SearchForMenu, SearchParentItem);

            return(View(menuItemList));
        }
예제 #15
0
        public ActionResult Index()
        {
            try
            {
                MenuItemModel menuItem = GetMenuItems().FirstOrDefault();
                if (menuItem != null)
                {
                    return(View());

                    //return RedirectToAction(
                    //    menuItem.WebAuthorization.ActionName,
                    //    menuItem.WebAuthorization.ControllerName);

                    //return RedirectToAction(
                    //    menuItem.ActionName,
                    //    menuItem.ControllerName);
                }
                else
                {
                    // 沒有任何MenuItem
                    return(RedirectToAction("Login", "Account"));
                }
                //return View();
            }
            catch (Exception ex)
            {
                this.logService.Error(ex);
                return(RedirectToAction("Login", "Account"));
            }
        }
예제 #16
0
        public async Task <ActionResult <MenuItemDetailDTO> > GetItem(int id)
        {
            MenuItemModel item = await this._context.MenuItemModel.FindAsync(id);

            if (item == null)
            {
                return(this.BadRequest());
            }

            await this._context.Entry(item).Reference(t => t.Category).LoadAsync();

            var result = new MenuItemDetailDTO
            {
                ID       = item.ID,
                Category = new MenuCategoryDTO
                {
                    ID   = item.Category.ID,
                    Name = item.Category.Name
                },
                Number      = item.Number,
                Name        = item.Name,
                Description = item.Description,
                Price       = item.Price
            };

            return(result);
        }
        public async Task <IHttpActionResult> Post(string moniker, MenuItemModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var menu = await _repository.GetMenuAsync(moniker);

                    if (menu != null)
                    {
                        var item = _mapper.Map <TheMealsApp.Classes.MenuItem>(model);
                        item.Menu = menu;
                        _repository.AddMenuItem(item);

                        if (await _repository.SaveChangesAsync())
                        {
                            return(CreatedAtRoute("GetItem",
                                                  new { moniker = moniker, id = item.Id },
                                                  _mapper.Map <MenuItemModel>(item)));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(BadRequest(ModelState));
        }
예제 #18
0
        /// <summary>
        /// 更新菜单项
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Menu Update(MenuItemModel model)
        {
            var menuItem = Find(model.Id);

            if (menuItem != null)
            {
                ValidateForUpdate(model);

                using (var trans = JMDbContext.Database.BeginTransaction())
                {
                    menuItem.TargetUrl             = model.TargetUrl;
                    menuItem.RequiredAuthorizeCode = model.RequiredAuthorizeCode;
                    menuItem.LastModificationTime  = DateTime.Now;

                    if (menuItem.Priority != model.Priority)
                    {
                        ResettingSiblingPriority(menuItem.Id, menuItem.ParentId, model.Priority);
                        menuItem.Priority = model.Priority;
                    }

                    Save();
                    trans.Commit();
                }
            }
            else
            {
                ThrowException("菜单项不存在!");
            }

            return(menuItem);
        }
        public async Task <IHttpActionResult> Put(string moniker, int itemId, MenuItemModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var item = await _repository.GetMenuItemByMonikerAsync(moniker, itemId, true);

                    if (item == null)
                    {
                        return(NotFound());
                    }

                    //It is going to ignore the menu
                    _mapper.Map(model, item);

                    if (await _repository.SaveChangesAsync())
                    {
                        return(Ok(_mapper.Map <MenuItemModel>(item)));
                    }
                    else
                    {
                        return(InternalServerError());
                    }
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
            return(BadRequest(ModelState));
        }
예제 #20
0
        private void LoadMenuItem(MenuItemModel item)
        {
            if (string.IsNullOrEmpty(item.Header))
            {
                ImGui.Separator();
                return;
            }

            if (item.MenuItems.Count > 0)
            {
                bool menuItem = ImGui.MenuItem(item.Header, "", true);
                var  hovered  = ImGui.IsItemHovered();

                if (menuItem && hovered)
                {
                    foreach (var c in item.MenuItems)
                    {
                        LoadMenuItem(c);
                    }
                    ImGui.EndMenu();
                }
            }
            else
            {
                if (ImGui.Selectable(item.Header))
                {
                    item.Command?.Execute(item);
                }
            }
        }
예제 #21
0
        public ActionResult EditMenuItem(MenuItemViewModel menuViewModel)
        {
            try {
                if (ModelState.IsValid)
                {
                    var menuItem = new MenuItemModel {
                        Id            = menuViewModel.Id,
                        MenuID        = menuViewModel.MenuID,
                        Url           = menuViewModel.Url,
                        PageID        = menuViewModel.PageID,
                        TitleMenuItem = menuViewModel.TitleMenuItem,
                        Weight        = menuViewModel.Weight
                    };
                    _menuItemManager.EditMenu(menuItem);

                    return(RedirectToAction("ManagementMenu"));
                }
            }
            catch (ValidationException ex) {
                ModelState.AddModelError(ex.Property, ex.Message);
            }
            ViewBag.Pages = GetPublishedPages();

            return(View(menuViewModel));
        }
예제 #22
0
파일: NavService.cs 프로젝트: t4rn/KrisApp
        /// <summary>
        /// Returns tech questions menu model
        /// </summary>
        private MenuItemModel PrepareQuestionMenu(User user)
        {
            MenuItemModel menu = new MenuItemModel()
            {
                Action     = "List",
                Controller = "Question",
                Text       = "Pytania",
            };

            if (user != null)
            {
                // zalogowany
                menu.SubMenu = new List <MenuItemModel>()
                {
                    new MenuItemModel {
                        Action = "AddQuestion", Controller = "Question", Text = "Dodaj pytanie"
                    },
                    new MenuItemModel {
                        Action = "List", Controller = "Question", Text = "Przeglądaj"
                    }
                };
            }

            return(menu);
        }
예제 #23
0
        /// <summary>
        /// 构建用于导入的LinkItem的数据
        /// LinkPath = 对应页面的MenuId + @ +对应页面的LinkPath
        /// </summary>
        /// <param name="dataItem"></param>
        /// <param name="collection"></param>
        /// <returns></returns>
        private MenuItemModel BuildLinkItem(MenuItemModel dataItem, ObservableCollection <MenuItemModel> collection, ref ObservableCollection <MenuItemModel> list)
        {
            var sourcePage = collection.SingleOrDefault(item => item.MenuId.ToString() == dataItem.LinkPath);

            if (sourcePage != null)
            {
                dataItem = new MenuItemModel
                {
                    DisplayName   = dataItem.DisplayName,
                    MenuId        = dataItem.MenuId,
                    LinkPath      = sourcePage.MenuId + "@" + sourcePage.LinkPath,
                    Type          = dataItem.Type,
                    ParentMenuId  = dataItem.ParentMenuId,
                    ApplicationId = dataItem.ApplicationId
                };

                if (!list.Contains(sourcePage))
                {
                    list.Add(sourcePage);
                    GetParents(sourcePage, collection, ref list);
                }
            }

            return(dataItem);
        }
 public MainMenuItemViewModel(MenuItemModel viewModel, INavigationService navigationService)
 {
     Title               = viewModel.Title.ToReadOnlyReactiveProperty();
     ImageSource         = viewModel.ImageSource.ToReadOnlyReactiveProperty();
     Tapped              = new ReactiveCommand();
     _tappedSubscription = Tapped.Subscribe((x) => { navigationService.ResetStack(viewModel.CreatePage.Invoke()); });
 }
예제 #25
0
 public IActionResult Index(CategoryViewModel vm)
 {
     // only build the catalogue once
     if (HttpContext.Session.Get <List <Category> >("categories") == null)
     {
         // no session information so let's go to the database
         try
         {
             CategoryModel catModel = new CategoryModel(_db);
             // now load the categories
             List <Category> categories = catModel.GetAll();
             HttpContext.Session.Set <List <Category> >("categories", categories);
             vm.SetCategories(categories);
         }
         catch (Exception ex)
         {
             ViewBag.Message = "Catalogue Problem - " + ex.Message;
         }
     }
     else
     {
         // no need to go back to the database as information is already in the session
         vm.SetCategories(HttpContext.Session.Get <List <Category> >("categories"));
         MenuItemModel itemModel = new MenuItemModel(_db);
         vm.MenuItems = itemModel.GetAllByCategory(vm.Id);
     }
     return(View(vm));
 }
예제 #26
0
        public async Task <ActionResult> AddImageAsync(HttpPostedFileBase file, int itemid)
        {
            if (file != null && file.ContentLength > 0)
            {
                try
                {
                    string path = Path.Combine(Server.MapPath("~/Content/assets/img/"),
                                               Path.GetFileName(file.FileName));
                    file.SaveAs(path);

                    MenuItemRepository rep = new MenuItemRepository(sqlConnection);
                    MenuItemModel      md  = await rep.GetItemById(itemid);

                    md.Image    = file.FileName;
                    md.Modified = DateTime.UtcNow;
                    await rep.UpdateItem(md);

                    ViewBag.Message = "File uploaded successfully";
                }
                catch (Exception ex)
                {
                    ViewBag.Message = "ERROR:" + ex.Message.ToString();
                }
            }
            else
            {
                ViewBag.Message = "You have not specified a file.";
            }
            return(Redirect("/Menu/Edit/" + itemid.ToString()));
        }
예제 #27
0
        public ActionResult UpdateMenuItem(MenuItemModel menuItemmodel)
        {
            var menuitem = Map(menuItemmodel);

            _repository.UpdateMenuItem(menuitem);
            return(Redirect("/Menu"));
        }
예제 #28
0
        private void InitUi()
        {
            var changeProfileItem = new MenuItemModel
            {
                Title      = "Change Profile",
                TapCommand = ChangeProfileCommand
            };

            var jobOffersItem = new MenuItemModel
            {
                Title      = "Job offers",
                TapCommand = JobOffersCommand
            };

            var introductionItem = new MenuItemModel
            {
                Title      = "Introduction",
                TapCommand = IntroductionCommand
            };

            var settingsItem = new MenuItemModel
            {
                Title      = "Settings",
                TapCommand = SettingsCommand
            };

            var privacyItem = new MenuItemModel
            {
                Title      = "Privacy",
                TapCommand = PrivacyCommand
            };

            var buyTokensItem = new MenuItemModel
            {
                Title      = "Buy Tokens",
                TapCommand = BuyTokensCommand
            };

            var eventsItem = new MenuItemModel
            {
                Title      = "Events",
                TapCommand = EventsCommand
            };

            var logoutItem = new MenuItemModel
            {
                Title      = "Logout",
                TapCommand = LogoutCommand
            };


            MenuItems.Add(changeProfileItem);
            MenuItems.Add(jobOffersItem);
            MenuItems.Add(introductionItem);
            MenuItems.Add(settingsItem);
            MenuItems.Add(privacyItem);
            MenuItems.Add(buyTokensItem);
            MenuItems.Add(eventsItem);
            MenuItems.Add(logoutItem);
        }
예제 #29
0
        public ActionResult CreateItem(int menuId)
        {
            if (!CheckPermission(MenusPermissions.ManageMenus))
            {
                return(new HttpUnauthorizedResult());
            }

            var model = new MenuItemModel
            {
                MenuId  = menuId,
                Enabled = true
            };

            var result = new ControlFormResult <MenuItemModel>(model)
            {
                Title                = T("Create Menu Item").Text,
                UpdateActionName     = "UpdateItem",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            var menuItems = GetMenuItems(menuItemService.GetMenuItems(menuId));

            result.RegisterExternalDataSource(x => x.ParentId, menuItems.ToDictionary(x => x.Id, x => x.Text.Replace("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", "\xA0\xA0\xA0\xA0\xA0")));

            return(result);
        }
예제 #30
0
        /// <summary>
        /// Method used to read the metamenu file generated from this application.
        /// </summary>
        /// <param name="aPath">The path to were the file is that we want to read from</param>
        /// <param name="anApplications">A Dictionary that will be populated with XML data</param>
        private static void LoadMenus(string aPath, Dictionary <string, ApplicationXMLModel> anApplications)
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(aPath);
                //Read the applications. e.g. Warehouse, Transportation
                XmlNode applicationsNode = doc.SelectSingleNode("/Applications");

                foreach (XmlNode applicationNode in applicationsNode)
                {
                    ApplicationXMLModel application = new ApplicationXMLModel();
                    //Give the RootNode a name e.g. Warehouse
                    XmlNode applicationNameNode = applicationNode.SelectSingleNode("Name");
                    ThrowIfNull(applicationNameNode,
                                "applicationNameNode was null in LoadMenus method");
                    application.Name = applicationNameNode.InnerText;

                    XmlNode topMenuItemNode = applicationNode.SelectSingleNode("Menu/MenuItem");
                    ThrowIfNull(applicationNameNode,
                                "topMenuItemNode was null in LoadMenus method");

                    MenuItemModel topMenuItemModel = new MenuItemModel();

                    XmlNode captionTopMenuItemNode = topMenuItemNode.SelectSingleNode("Caption");
                    ThrowIfNull(captionTopMenuItemNode,
                                "captionTopMenuItemNode was null in LoadMenus method");
                    topMenuItemModel.Caption = captionTopMenuItemNode.InnerText;

                    XmlNode identityTopMenuItemNode = topMenuItemNode.SelectSingleNode("Id");
                    ThrowIfNull(identityTopMenuItemNode,
                                "identityTopMenuItemNode was null in LoadMenus method");
                    topMenuItemModel.Identity = identityTopMenuItemNode.InnerText;

                    topMenuItemModel.Actions = null;

                    XmlNode topMenuChildrenNode = topMenuItemNode.SelectSingleNode("Children");
                    ThrowIfNull(topMenuChildrenNode,
                                "topMenuChildrenNode was null in LoadMenus method");

                    foreach (XmlNode menuItemChildren in topMenuChildrenNode)
                    {
                        MenuItemModel menuItemModel = LoadMenu(menuItemChildren);
                        ThrowIfNull(menuItemModel, "A child node in topMenu was null in LoadMenus method");

                        topMenuItemModel.Children.Add(menuItemModel);
                    }
                    application.MenuItems = topMenuItemModel;
                    anApplications.Add(application.Name, application);
                }
            }
            catch (Exception ex)
            {
                if (ex is FileNotFoundException)
                {
                    MessageBox.Show("MetaMenu.XML not found!", "", MessageBoxButtons.OK);
                }
            }
        }