public MainWindowViewModel(MainWindow mainWindow)
 {
     _mainWindow        = mainWindow;
     _consumer          = new AdminAPIConsumer(Properties.Settings.Default.ServerAddress);
     _newProjectCommand = new RelayCommand(AddNewProjectAsync);
     _newPageCommand    = new RelayCommand(AddNewPage);
     _newMenuCommand    = new RelayCommand(AddNewMenu);
     _deleteCommand     = new RelayCommand(DeleteAsync);
     ConstructTreeView();
 }
        public bool CostructSite(string siteName, string pageName)
        {
            _consumer = new AdminAPIConsumer(serverAddress);

            siteName     = !string.IsNullOrEmpty(siteName) ? siteName : defaultPage;
            _currentSite = _consumer.GetSiteByNameAsync(siteName);
            if (_currentSite == null)
            {
                return(false);
            }
            ViewBag.SiteName   = _currentSite.Name;
            _currentSite.Pages = _consumer.GetPageForSite(_currentSite.SiteId).ToList();
            _currentSite.Menus = _consumer.GetMenusForSite(_currentSite.SiteId).ToList();

            if (!string.IsNullOrEmpty(pageName))
            {
                var page = _currentSite.Pages.FirstOrDefault(p => p.Name.ToLower() == pageName.ToLower());

                if (page != null)
                {
                    _currentPage = page;
                }
            }
            if (_currentPage == null)
            {
                if (_currentSite.Pages.Count == 0)
                {
                    return(false);
                }
                _currentPage = _currentSite.Pages.ToList()[_currentSite.StartPage];
            }
            if (_currentSite.Menus.Count > 0)
            {
                _currentMenu = _currentSite.Menus.ToList().First();
            }
            if (_currentMenu != null)
            {
                ViewBag.Menu = Settings.ConvertFromJson(_currentMenu.ControlsJson);
            }

            return(true);
        }
 public AddWindow(Base.Menu menu, AdminAPIConsumer consumer, MainWindowViewModel mainWindowVM) : this(consumer, mainWindowVM)
 {
     this.menu = menu;
     this.type = 2;
     InitializeComponent();
 }
 public AddWindow(Base.Page page, AdminAPIConsumer consumer, MainWindowViewModel mainWindowVM) : this(consumer, mainWindowVM)
 {
     this.page = page;
     this.type = 1;
     InitializeComponent();
 }
 public AddWindow(Base.Site site, AdminAPIConsumer consumer, MainWindowViewModel mainWindowVM) : this(consumer, mainWindowVM)
 {
     this.site = site;
     this.type = 0;
     InitializeComponent();
 }
 public AddWindow(AdminAPIConsumer consumer, MainWindowViewModel mainWindowVM)
 {
     this.mainWindowVM = mainWindowVM;
     this.consumer     = consumer;
     InitializeComponent();
 }