Пример #1
0
        // GET: Actors
        public ActionResult Index()
        {
            var model = new ActorsListViewModel();

            model.ActorsList = _actorService.GetAll();
            return(View(model));
        }
Пример #2
0
        public ActionResult AllActorsView()
        {
            var actorsListViewModel = new ActorsListViewModel
            {
                AllActors = _allactors.AllActors().ToList()
            };

            return(View(actorsListViewModel));
        }
Пример #3
0
        public ActionResult Index(int?page, string searchString = null)
        {
            ViewBag.ActorFilter = searchString;
            var actors              = _actorDataProvider.GetActorBySearchString(searchString, ApplicationUser);
            var pageSize            = 5;
            var pageNumber          = (page ?? 1);
            var actorsListViewModel = new ActorsListViewModel()
            {
                Actors = actors.ToPagedList(pageNumber, pageSize)
            };

            return(View(actorsListViewModel));
        }
        public IActionResult Index(string sortColumn, string sortOrder, string page, string pageSize)
        {
            var pageSizeConverted = 0;

            if (string.IsNullOrEmpty(pageSize))
            {
                if (string.IsNullOrEmpty(HttpContext.Session.GetString("pageSize")))
                {
                    pageSizeConverted = 50;
                    HttpContext.Session.SetString("pageSize", pageSizeConverted.ToString());
                }
                else
                {
                    pageSizeConverted = Convert.ToInt32(HttpContext.Session.GetString("pageSize"));
                }
                //pageSizeConverted = 50;
            }
            else
            {
                HttpContext.Session.SetString("pageSize", pageSize.ToString());
                pageSizeConverted = Convert.ToInt32(pageSize);
            }

            var actonListViewModel = new ActorsListViewModel();
            var items = _repository.GetAllActors().Select(actor => new ActorItemViewModel
            {
                ActorId   = actor.ActorId,
                FirstName = actor.FirstName,
                LastName  = actor.LastName
            });

            items = _sortingLogic.SortActorList(ref sortColumn, ref sortOrder, items);

            var pageCount   = (double)items.Count() / pageSizeConverted;
            int currentPage = string.IsNullOrEmpty(page) ? 1 : Convert.ToInt32(page);

            items = items.Skip((currentPage - 1) * pageSizeConverted).Take(pageSizeConverted);

            actonListViewModel.PagingViewModel.MaxPages    = (int)Math.Ceiling(pageCount);
            actonListViewModel.PagingViewModel.CurrentPage = currentPage;
            actonListViewModel.PagingViewModel.pageSize    = pageSizeConverted.ToString();
            actonListViewModel.Items      = items.ToList();
            actonListViewModel.SortColumn = sortColumn;
            actonListViewModel.SortOrder  = sortOrder;
            return(View(actonListViewModel));
        }
Пример #5
0
        public ViewResult List(string category, int page = 1)
        {
            ActorsListViewModel actorsModel = new ActorsListViewModel
            {
                Actors = repository.Actors.
                         Where(a => category == null || a.Category == category).
                         OrderBy(a => a.ID).
                         Skip((page - 1) * PageSize).
                         Take(PageSize),

                PagingInformation = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = PageSize,
                    TotalItems   = category == null?repository.Actors.Count() : repository.Actors.Where(e => e.Category == category).Count()
                },
                CurrentCategory = category
            };

            return(View(actorsModel));
        }