public async Task <IActionResult> OrdersByDate(DateTime date, int page = 1)
        {
            int pageSize = 10;

            ViewBag.date = date;
            var user = await _userManager.FindByNameAsync(HttpContext.User.Identity.Name);

            var entityBase      = from m in _context.EntityBase select m;
            var allOrdersByDate = entityBase
                                  .Where(s => s.TheUser.Contains(user.UserName))
                                  .Where(s => s.Family.Contains("noFamily"))
                                  .Where(a => a.DateAdded.Year == date.Year)
                                  .Where(a => a.DateAdded.Month == date.Month)
                                  .Where(a => a.DateAdded.Day == date.Day)
                                  .OrderByDescending(p => p.DateAdded);

            var count = await allOrdersByDate.CountAsync();

            var items = await allOrdersByDate.Skip((page - 1) *pageSize).Take(pageSize).ToListAsync();

            PageViewModel      pageViewModel = new PageViewModel(count, page, pageSize);
            PageIndexViewModel viewModel     = new PageIndexViewModel
            {
                PageViewModel = pageViewModel,
                EntityBases   = items
            };

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public ActionResult Index(string searchString, int page = 1)
        {
            int pageSize = 5;

            var shows   = new List <ShowViewModel>();
            var dbShows = db.GetShows();

            foreach (var show in dbShows)
            {
                shows.Add(new ShowViewModel
                {
                    Id          = show.Id,
                    Name        = show.Name,
                    Seasons     = show.Seasons,
                    Episodes    = show.Episodes,
                    Description = show.Description
                });
            }

            if (!String.IsNullOrEmpty(searchString))
            {
                shows = shows.Where(show => show.Name.ToLower().Contains(searchString.ToLower())).ToList();
            }
            IEnumerable <ShowViewModel> showsPerPage = shows.Skip((page - 1) * pageSize).Take(pageSize);
            PageInfo pageInfo = new PageInfo {
                PageNumber = page, PageSize = pageSize, TotalItems = shows.Count()
            };
            PageIndexViewModel ivm = new PageIndexViewModel {
                PageInfo = pageInfo, Shows = showsPerPage
            };

            return(View(ivm));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Index(DateTime date, string familyId, int page = 1)
        {
            int pageSize = 10;

            if (date != DateTime.MinValue)
            {
                ViewBag.date = date;
                var entityBase1     = from m in _context.EntityBase select m;
                var allOrdersByDate = entityBase1
                                      .Where(s => s.Family.Contains(familyId))
                                      .Where(a => a.DateAdded.Year == date.Year)
                                      .Where(a => a.DateAdded.Month == date.Month)
                                      .Where(a => a.DateAdded.Day == date.Day)
                                      .OrderByDescending(p => p.DateAdded);

                var count1 = await allOrdersByDate.CountAsync();

                var items1 = await allOrdersByDate.Skip((page - 1) *pageSize).Take(pageSize).ToListAsync();

                PageViewModel      pageViewModel1 = new PageViewModel(count1, page, pageSize);
                PageIndexViewModel viewModel1     = new PageIndexViewModel
                {
                    PageViewModel = pageViewModel1,
                    EntityBases   = items1
                };
                return(View(viewModel1));
            }
            var entityBase = from m in _context.EntityBase select m;

            entityBase = entityBase
                         .Where(s => s.Family.Contains(familyId))
                         .OrderByDescending(p => p.DateAdded);
            Family family = dataManager.Family.GetFamilyById(familyId);

            ViewBag.familyId    = familyId;
            ViewBag.familyName  = family.Name;
            ViewBag.familyAdmin = family.FAdmin;


            var count = await entityBase.CountAsync();

            var items = await entityBase.Skip((page - 1) *pageSize).Take(pageSize).ToListAsync();

            PageViewModel      pageViewModel = new PageViewModel(count, page, pageSize);
            PageIndexViewModel viewModel     = new PageIndexViewModel
            {
                PageViewModel = pageViewModel,
                EntityBases   = items
            };

            return(View(viewModel));
        }
        private object getViewModelFrom(List <CMS.Core.Entity.Page> pages)
        {
            PageIndexViewModel vm = new PageIndexViewModel();

            vm.page_details = new List <PageDetailModel>();
            foreach (var page in pages)
            {
                var pageDetail = _mapper.Map <PageDetailModel>(page);
                pageDetail.page_category_name = page.page_category.name;
                vm.page_details.Add(pageDetail);
            }

            return(vm);
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> NewsManagement(int page = 1)
        {
            var news = await _newsService.GetAllNewsAsync();

            news = news.OrderByDescending(s => s.DateOfCreating);
            int                pageSize      = 10;
            var                count         = news.Count();
            var                items         = news.Skip((page - 1) * pageSize).Take(pageSize).ToList();
            PageViewModel      pageViewModel = new PageViewModel(count, page, pageSize);
            PageIndexViewModel viewModel     = new PageIndexViewModel
            {
                PageViewModel = pageViewModel,
                EnumNews      = items
            };

            return(View(viewModel));
        }