コード例 #1
0
        public ViewModels.DictaatPageSummary Post(string dictaatName, [FromBody] ViewModels.DictaatPageForm form)
        {
            var MenuItem = new ViewModels.MenuItem()
            {
                Name = form.Page.Name,
                Url  = form.Page.Name
            };

            var result = _pageRepo.CreateDictaatPage(dictaatName, form.Page);

            _menuRepo.AddMenuItem(dictaatName, form.SubMenu, MenuItem);
            return(result);
        }
コード例 #2
0
        public ViewModels.Menu AddMenuItem(string dictaat, string subMenu, ViewModels.MenuItem item)
        {
            var menu = GetMenu(dictaat);

            if (subMenu != null)
            {
                menu.SubMenus.FirstOrDefault(s => s.Name.Equals(subMenu))
                .MenuItems.Add(item);
            }
            else
            {
                menu.MenuItems.Add(item);
            }

            menu = EditMenu(dictaat, menu);
            return(menu);
        }
コード例 #3
0
        public async Task <List <ViewModels.MenuItem> > Post(string dictaatName, [FromBody] ViewModels.DictaatPageForm form)
        {
            if (!AuthorizeResource(dictaatName))
            {
                return(null);
            }

            if (!ModelState.IsValid)
            {
                HttpContext.Response.StatusCode = 400;
                return(null);
            }

            var MenuItem = new ViewModels.MenuItem()
            {
                Name = form.Page.Name,
                Url  = form.Page.Url
            };

            var result = _pageRepo.CreateDictaatPage(dictaatName, form.Page, form.TemplateName);
            var menu   = _menuRepo.AddMenuItem(dictaatName, form.SubMenu, MenuItem);

            return(menu);
        }
コード例 #4
0
        public List <ViewModels.MenuItem> AddMenuItem(string dictaat, string parentMenu, ViewModels.MenuItem item)
        {
            var menu = GetMenu(dictaat);

            if (parentMenu != null)
            {
                MenuItem parent = menu.FirstOrDefault(s => s.Name.Equals(parentMenu));
                if (parent != null)
                {
                    parent.MenuItems.Add(item);
                }
            }
            else
            {
                menu.Add(item);
            }

            return(EditMenu(dictaat, menu));
        }