Esempio n. 1
0
        // GET: Category
        public ActionResult Index(int?numRows, bool?showHistoricalData)
        {
            if (numRows == null)
            {
                // set default of X per page (we can choose something suitable 0 gets all)
                numRows = 10;
            }

            if (showHistoricalData == null)
            {
                // set default of X per page (we can choose something suitable 0 gets all)
                showHistoricalData = Models.Constants.SHOW_HISTORICAL_DATA;
            }

            var viewModel = new IndexCategoryViewModel();

            viewModel.Users              = _applicationDb.Users.ToList();
            viewModel.Categories         = _db.Categories.ToList().Where(c => c.ParentId == null).OrderBy(c => c.Name);
            viewModel.RowsPerPage        = Convert.ToInt32(numRows);
            viewModel.RowOptions         = Models.Constants.ROW_OPTIONS;
            viewModel.ShowHistoricalData = showHistoricalData;


            return(View(viewModel));
        }
Esempio n. 2
0
        // GET: Categorie
        public async Task <IActionResult> Index()
        {
            IndexCategoryViewModel indexCategoryViewModel = new IndexCategoryViewModel();

            indexCategoryViewModel.Categories = await _context.Categories.Include(c => c.Parent).Where(c => c.ParentId != null).ToListAsync();

            return(View(indexCategoryViewModel));
        }
Esempio n. 3
0
        public ActionResult Index()
        {
            var categoryService = new CategoryService();
            var model           = new IndexCategoryViewModel();

            model.Categories = categoryService.SearchCategories(new SearchCategoriesRequest()).Categories.ToList();

            return(View(model));
        }
Esempio n. 4
0
        public async Task <IActionResult> Category()
        {
            var categoryViewModel = new IndexCategoryViewModel()
            {
                Categories = await this.categoriesService.GetAllAsync(),
            };

            return(this.View(categoryViewModel));
        }
        public async Task <IActionResult> Index()
        {
            var categories = await this.categoryService.GetAll();

            var viewModel = new IndexCategoryViewModel
            {
                Categories = categories.ToList(),
            };

            return(this.View(viewModel));
        }
Esempio n. 6
0
        public ActionResult Index(int page = 1)
        {
            var categories     = _categoryService.GetCategories();
            var categoriesList = categories.Select(Mapper.Map <Category, CategoryViewModel>).Skip((page - 1) * pageSize).Take(pageSize).ToList();
            var pager          = new Pager(page, categories.Count(), pageSize);
            var model          = new IndexCategoryViewModel
            {
                Categories = categoriesList,
                Pager      = pager
            };

            return(View(model));
        }
Esempio n. 7
0
        //GET: Searchfilter

        public async Task <IActionResult> Search(IndexCategoryViewModel indexCategoryViewModel)
        {
            if (!string.IsNullOrEmpty(indexCategoryViewModel.CategorySearch))
            {
                indexCategoryViewModel.Categories = await _context.Categories.Include(c => c.Parent)
                                                    .Where(c => c.Name.Contains(indexCategoryViewModel.CategorySearch))
                                                    .Where(c => c.ParentId != null).ToListAsync();
            }
            else
            {
                indexCategoryViewModel.Categories = await _context.Categories.Include(c => c.Parent).ToListAsync();
            }
            return(View("Index", indexCategoryViewModel));
        }
Esempio n. 8
0
        // GET: Categories
        public ActionResult Index()
        {
            var ViewModel  = new IndexCategoryViewModel();
            var categories = (
                from node in db.Categories
                orderby node.LftId ascending
                select new
            {
                LftId = node.LftId,
                RgtId = node.RgtId,
                Name = node.Name,
                Id = node.Id,
                //find all when left < myleft and right > myright will give you all parents
                Depth = (
                    from parent in db.Categories
                    where parent.LftId <node.LftId && parent.RgtId> node.RgtId
                    select(parent.Id)
                    ).Count()
            }
                ).ToList();
            List <CategoryRow> CategoryList = new List <CategoryRow>();

            //Create new viemodel, which will be named 'IndexCategoryViewModel
            foreach (var cat in categories)
            {
                CategoryRow category = new CategoryRow();
                category.Name  = cat.Name;
                category.Id    = cat.Id;
                category.Depth = cat.Depth;
                category.LftId = cat.LftId;
                category.RgtId = cat.RgtId;
                CategoryList.Add(category);
            }

            ViewModel.categories = CategoryList;
            return(View(ViewModel));
        }
 //
 // GET: /Category/
 public ActionResult Index()
 {
     var vm = new IndexCategoryViewModel
     {
         Categories = this.categoryService.GetCategories()
     };
     return View(vm);
 }