public MainWindowViewModel()
 {
     CategoryTreeViewModel            = new CategoryTreeViewModel();
     DirectoryTreeViewModel           = new DirectoryTreeViewModel();
     IndexMediaFilesViewModel         = new IndexMediaFilesViewModel();
     DirectoryTreeViewModel.OnChange += IndexMediaFilesViewModel.ChangeDirectory;
     CategoryTreeViewModel.OnChange  += IndexMediaFilesViewModel.ChangeCategory;
 }
        public Task <IViewComponentResult> InvokeAsync(CategoryTreeViewModel model)
        {
            if (model == null)
            {
                model = new CategoryTreeViewModel();
            }

            return(Task.FromResult((IViewComponentResult)View(model)));
        }
Beispiel #3
0
        public Task <IViewComponentResult> InvokeAsync(List <Category> categories, bool isFirstCall)
        {
            if (isFirstCall)
            {
                categories = _service.GetCategoryTree();
            }

            var viewModel = new CategoryTreeViewModel {
                IsFirstCall = isFirstCall, Categories = categories
            };

            //something is not going right and I needed to explicitly state return type here.
            return(Task.FromResult <IViewComponentResult>(View(viewModel)));
        }
        // GET: Categories/Details
        public IActionResult Details()
        {
            var viewModel = new CategoryTreeViewModel();

            try
            {
                var jstree = _categoryService.GetCategoriesAsJSTree(CountryId);
                viewModel = new CategoryTreeViewModel {
                    CategoriesAsTree = jstree, PathString = CountryPath
                };
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
                return(NotFound().WithError(ex.Message));
            }

            return(View(viewModel));
        }
        public ActionResult SaveCategoryTree(CategoryTreeViewModel model)
        {
            if (ModelState.IsValid)
            {
                var response = GetCommand <SaveCategoryTreeCommand>().ExecuteCommand(model);
                if (response != null)
                {
                    if (model.Id.HasDefaultValue())
                    {
                        Messages.AddSuccess(RootGlobalization.CategoryTree_CategoryTreeCreatedSuccessfully_Message);
                    }

                    return(Json(new WireJson {
                        Success = true, Data = response
                    }));
                }
            }

            return(Json(new WireJson {
                Success = false
            }));
        }
        private void StripUnusedTreeFields(CategoryTreeViewModel vm)
        {
            vm.ParentCategoryId = null;

            if (vm.Children == null || vm.Children.Count == 0)
            {
                vm.Children = null;
                return;
            }

            foreach (var child in vm.Children)
            {
                this.StripUnusedTreeFields(child);
            }
        }