public void New(RoutedEventArgs e)
        {
            var menuItem = e.Source as MenuItem;
            var header   = menuItem.Header.ToString();

            int type = 0;

            if (header.ToLower() == "folder")
            {
                type = 1;
            }
            else if (header.ToLower() == "file")
            {
                type = 2;
            }
            else if (header.ToLower() == "image")
            {
                type = 3;
            }

            var parentId = SelectedMenu.Id;

            var menuDto = new MenuModel
            {
                Name = "New " + header,
                Pid  = parentId,
                Type = type
            };

            _menuService.AddOrUpdate(menuDto).Then(r => {
                if (r.HasError())
                {
                    WindowManager.ShowErrorWindow(r.StatusCode);
                    return;
                }

                var menu = r.Data.Data;
                if (menu != null)
                {
                    SelectedMenu.Id = menu.Id;
                    menuDto.Id      = menu.Id;
                }
                menuDto.Icon   = IconUtility.GetIcon(menuDto.Type);
                menuDto.Parent = SelectedMenu;
                SelectedMenu.Children.Add(menuDto);
            });
        }
Exemplo n.º 2
0
 public ActionResult PostAdd(MenuModel Models)
 {
     if (CSer.AddOrUpdate(Models) == true)
     {
         return(Content("1"));
     }
     else
     {
         return(View(Models));
     }
 }
        public void New(RoutedEventArgs e)
        {
            var menuItem = e.Source as MenuItem;
            var header   = menuItem.Header.ToString();

            int type = 0;

            if (header.ToLower() == "folder")
            {
                type = 1;
            }
            else if (header.ToLower() == "file")
            {
                type = 2;
            }
            else if (header.ToLower() == "image")
            {
                type = 3;
            }

            var parentId = SelectedMenu.Id;

            var menuDto = new MenuModel
            {
                Name = "New " + header,
                Pid  = parentId,
                Type = type
            };

            var addResult = _menuService.AddOrUpdate(menuDto);
            var menu      = addResult.Data;

            if (menu != null)
            {
                SelectedMenu.Id = menu.Id;
                menuDto.Id      = menu.Id;
            }
            menuDto.Icon   = IconUtility.GetIcon(menuDto.Type);
            menuDto.Parent = SelectedMenu;
            SelectedMenu.Children.Add(menuDto);
        }