Пример #1
0
        public MenuCreateModel LoadCreate(long? languageID)
        {
            LanguageBusiness languageBusiness = new LanguageBusiness();

            MenuCreateModel menuCreateModel = new MenuCreateModel();
            MenuBusiness menuBusiness = new MenuBusiness();

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

            long defaultLanguageID = languageBusiness.GetFirstLanguage();

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

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

            List<SelectListItemModel> menuList = new List<SelectListItemModel>();

            menuList.Add(new SelectListItemModel
            {
                Text = "Ana menü",
                Value = null
            });

            menuList.AddRange(menuBusiness.MenuSelectListByLanguageID(languageID.Value));

            menuCreateModel.MenuList = new SelectList(menuList, "Value", "Text");

            return menuCreateModel;
        }
Пример #2
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;
        }