Exemplo n.º 1
0
        // GET: Administration/Home
        public ActionResult Index()
        {
            int postsCount = this.Data.Posts
                .All()
                .Count();

            int commentsCount = this.Data.Comments
                .All()
                .Count();

            int usersCount = this.Data.Users
                .All()
                .Count();

            int pagesCount = this.Data.Pages
                .All()
                .Count();

            var model = new IndexAdminPageViewModel
            {
                PostsCount = postsCount,
                CommentsCount = commentsCount,
                PagesCount = pagesCount,
                UsersCount = usersCount
            };

            return this.View(model);
        }
Exemplo n.º 2
0
        public IActionResult SearchProduct(string searchTerm, int?page)
        {
            if (string.IsNullOrEmpty(searchTerm))
            {
                return(RedirectToAction("Index"));
            }

            var products = this.productsService
                           .GetAll()
                           .Where(p => p.Name.ToLower().Contains(searchTerm.ToLower()))
                           .OrderByDescending(x => x.CreatedOn)
                           .Select(x => new ProductViewModel(x))
                           .ToList();

            Pager pager = new Pager(products.Count(), page);

            IndexAdminPageViewModel viewPageIndexModel = new IndexAdminPageViewModel
            {
                Items = products.Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize).ToList(),
                Pager = pager
            };

            ViewData["searchTerm"] = searchTerm;

            return(View(viewPageIndexModel));
        }
Exemplo n.º 3
0
        // GET: Administration/Home
        public ActionResult Index()
        {
            var blogPosts        = this.Data.Posts.All().Count();
            var comments         = this.Data.PostComments.All().Count();
            var applicationUsers = this.Data.Users.All().Count();

            var model = new IndexAdminPageViewModel
            {
                BlogPostsCount        = blogPosts,
                CommentsCount         = comments,
                ApplicationUsersCount = applicationUsers
            };

            return(this.View(model));
        }
Exemplo n.º 4
0
        public IActionResult Index(int?page)
        {
            var products = this.productsService
                           .GetAll()
                           .OrderByDescending(x => x.CreatedOn)
                           .Select(x => new ProductViewModel(x))
                           .ToList();

            Pager pager = new Pager(products.Count(), page);

            IndexAdminPageViewModel viewPageIndexModel = new IndexAdminPageViewModel
            {
                Items = products.Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize).ToList(),
                Pager = pager
            };

            return(View(viewPageIndexModel));
        }