// GET: Ajax public ActionResult GetCategorizedProductByPage(int cateId, int page) { var products = Context.GetItems(i => i.CategoryId == cateId); var paging = new PagingHelper().GetPageInfo(products.Count(), page, 9); var result = products.ToList().GetRange(paging.StartIndex, paging.Count).Select(i => new ProductModel(i)); var model = new PagingViewModel<ProductModel>(paging, result.ToList()); return View(); }
public Task<IViewComponentResult> InvokeAsync(string areaName, string controlerName, string actionName, int currentPage, int pageSize, int totalRecords, Dictionary<string, string> routeValues) { PagingViewModel pagin = new PagingViewModel(); pagin.CurrentPage = currentPage; pagin.PageSize = pageSize; pagin.TotalRecords = totalRecords; pagin.AreaName = areaName; pagin.ControlerName = controlerName; pagin.ActionName = actionName; pagin.RouteValues = routeValues; return Task.FromResult<IViewComponentResult>(View(pagin)); }
public async Task <IActionResult> Index(int page = 1) { IQueryable <Bank> banks = bankService.GetBankList().OrderBy(b => b.BIK); PagedObject <Bank> pagedObject = await pagingService.DoPage <Bank>(banks, page); PagingViewModel <Bank> BanksPagingViewModel = new PagingViewModel <Bank> { PageViewModel = new PageViewModel(pagedObject.Count, page, pagedObject.PageSize), Objects = pagedObject.Objects }; return(View(BanksPagingViewModel)); }
public async Task <IActionResult> PaymentCodeList(int page = 1) { IQueryable <PaymentСode> paymentCodies = paymentCodeService.GetPaymentСodeList().OrderBy(c => c.Code); PagedObject <PaymentСode> pagedObject = await pagingService.DoPage <PaymentСode>(paymentCodies, page); PagingViewModel <PaymentСode> PaymentCodiesPagingViewModel = new PagingViewModel <PaymentСode> { PageViewModel = new PageViewModel(pagedObject.Count, page, pagedObject.PageSize), Objects = pagedObject.Objects }; return(View(PaymentCodiesPagingViewModel)); }
public async Task <IActionResult> Index(int page = 1) { IQueryable <Limit> limits = limitService.GetLimitList().OrderBy(l => l.LimitName); PagedObject <Limit> pagedObject = await pagingService.DoPage <Limit>(limits, page); PagingViewModel <Limit> LimitsPagingViewModel = new PagingViewModel <Limit> { PageViewModel = new PageViewModel(pagedObject.Count, page, pagedObject.PageSize), Objects = pagedObject.Objects }; return(View(LimitsPagingViewModel)); }
public PagingViewModel GetJobOffers(int pageNo, int pageSize = 6) { int totalOffers = context.JobOffers.Count(); int totalPage = (totalOffers / pageSize) + ((totalOffers % pageSize) > 0 ? 1 : 0); var offers = context.JobOffers.Include(o => o.Company).OrderBy(o => o.JobTitle).Skip((pageNo - 1) * pageSize).Take(pageSize).ToList(); var model = new PagingViewModel { Offers = offers, TotalPage = totalPage }; return(model); }
public async Task <IHttpActionResult> GetSetting(PagingViewModel model) { try { var setting = await _UnitOfWork.SettingRepository.All().FirstAsync(); return(Ok(setting)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <IActionResult> Index(int page = 1) { IQueryable <Company> companies = companyService.GetCompanies().OrderBy(c => c.NameCompany); PagedObject <Company> pagedObject = await pagingService.DoPage <Company>(companies, page); PagingViewModel <Company> CompaniesPagingViewModel = new PagingViewModel <Company> { PageViewModel = new PageViewModel(pagedObject.Count, page, pagedObject.PageSize), Objects = pagedObject.Objects }; return(View(CompaniesPagingViewModel)); }
public ActionResult <List <JobOffer> > OffersSearch(string searchString, int pageNumber = 1) { List <JobOffer> searchResult = _context.JobOfers.Include(item => item.Company).ToList(); if (!String.IsNullOrEmpty(searchString)) { searchResult = searchResult.FindAll(item => item.JobTitle.ToLower().Contains(searchString.ToLower())).ToList(); } PagingViewModel pagedOffers = PreparePagingViewModel(pageNumber, searchResult); return(Ok(pagedOffers)); }
public Task <IViewComponentResult> InvokeAsync(string areaName, string controlerName, string actionName, int currentPage, int pageSize, int totalRecords, Dictionary <string, string> routeValues) { PagingViewModel pagin = new PagingViewModel(); pagin.CurrentPage = currentPage; pagin.PageSize = pageSize; pagin.TotalRecords = totalRecords; pagin.AreaName = areaName; pagin.ControlerName = controlerName; pagin.ActionName = actionName; pagin.RouteValues = routeValues; return(Task.FromResult <IViewComponentResult>(View(pagin))); }
// GET: api/Users public IEnumerable <ListUserViewModel> GetUsers([FromUri] PagingViewModel pagingparametermodel, [FromUri] string keyWord = "") { var result = new List <User>(); var users = db.Users.Where(m => m.Deleted != true); if (keyWord != null && keyWord.Length > 0) { result = users.Where(m => m.Username.Contains(keyWord) || m.FirstName.Contains(keyWord) || m.LastName.Contains(keyWord) || m.Email.Contains(keyWord) || m.Phone.Contains(keyWord)).ToList(); } else { result = users.ToList(); } var source = result.OrderByDescending(m => m.ID).Select(user => new ListUserViewModel { ID = user.ID, Username = user.Username, FirstName = user.FirstName, LastName = user.LastName, Phone = user.Phone, Email = user.Email, PhotoImage = user.Image.Path, Active = user.Active == true ? "Đang hoạt động" : "Ngừng hoạt động", Created = user.Created }).AsQueryable(); int count = source.Count(); int CurrentPage = pagingparametermodel.pageNumber; int PageSize = pagingparametermodel.pageSize; int TotalCount = count; int TotalPages = (int)Math.Ceiling(count / (double)PageSize); var items = source.Skip((CurrentPage - 1) * PageSize).Take(PageSize).ToList(); var previousPage = CurrentPage > 1 ? "Yes" : "No"; var nextPage = CurrentPage < TotalPages ? "Yes" : "No"; // Object which we are going to send in header var paginationMetadata = new { totalCount = TotalCount, pageSize = PageSize, currentPage = CurrentPage, totalPages = TotalPages, previousPage, nextPage }; // Setting Header HttpContext.Current.Response.Headers.Add("Paging-Headers", JsonConvert.SerializeObject(paginationMetadata)); // Returing List of Customers Collections return(items); }
public async Task <IEnumerable <User> > GetUsers(PagingViewModel paging) { List <UserIdentity> users = null; if (!string.IsNullOrEmpty(paging.Search)) { users = await _userManager.Users.Where(UserFind(paging.Search)).Skip((paging.Page - 1) * paging.Quantity).Take(paging.Quantity).ToListAsync(); } else { users = await _userManager.Users.Skip((paging.Page - 1) *paging.Quantity).Take(paging.Quantity).ToListAsync(); } return(users.Select(GetUser)); }
public List <BankAccountViewModel> Search(BankAccountQueryCondition cond, PagingViewModel paging) { return(this.GetSearchIQuerable(cond).OrderByDescending(x => x.Id).Skip(paging.Skip).Take(paging.Take).AsNoTracking().Select(x => new BankAccountViewModel() { AccountName = x.帳戶名稱, AccountNumber = x.帳戶號碼, BankCode = x.銀行代碼, BankName = x.銀行名稱, BankSubCode = x.分行代碼, CompanyNumber = x.客戶資料.統一編號, CustomerName = x.客戶資料.客戶名稱, Id = x.Id }).ToList()); }
public async Task <IHttpActionResult> GetSetting(PagingViewModel model) { try { var contactUs = await _UnitOfWork.ContactUsRepository.All().OrderBy(x => x.Id).Skip(model.PageSize * model.PageNumber) .Take(model.PageSize).ToListAsync(); return(Ok(contactUs)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <IEnumerable <User> > GetUsers(PagingViewModel paging) { List <UserIdentity> users = null; if (paging.Search.IsPresent()) { users = await _userManager.Users.Where(UserFind(paging.Search)).Skip(paging.Offset).Take(paging.Limit).ToListAsync(); } else { users = await _userManager.Users.Skip(paging.Offset).Take(paging.Limit).ToListAsync(); } return(users.Select(GetUser)); }
public ActionResult Index(int?currentTopic, int page = 1) { var categories = categoryService.Get(); ViewBag.Categories = categories; var topic = topicService.FindById((int)currentTopic); PagingViewModel <Comment> viewModel = new PagingViewModel <Comment>(page, PAGE_SIZE, topic.Comments) { Id = topic.Id, Name = topic.Description }; return(View(viewModel)); }
public async Task <ActionResult> Index(int id, int page = 1) { IQueryable <EmployeeInfo> employees = employeeService.GetEmployeesByCompanyId(id).OrderBy(c => c.FirstName); PagedObject <EmployeeInfo> pagedObject = await pagingService.DoPage <EmployeeInfo>(employees, page); PagingViewModel <EmployeeInfo> EmployeePagingViewModel = new PagingViewModel <EmployeeInfo> { PageViewModel = new PageViewModel(pagedObject.Count, page, pagedObject.PageSize), Objects = pagedObject.Objects }; ViewBag.CompanyId = id; return(View(EmployeePagingViewModel)); }
public PagingViewModel <TViewModel> GetByAllPage(PagingViewModel <TViewModel> page, params string[] includeProperties) { try { var model = _baseService.GetAll(includeProperties).Paging(page.Number, page.Size, page.OrderBy, page.OrderDirection); page.List = model.Item1.MapTo <List <TViewModel> >(); page.TotalCount = model.Item2; return(page); } catch (Exception e) { throw e; } }
protected internal PagingViewModel CalcPaging(int limit, int?page, int count) { var paging = new PagingViewModel { Count = count, Page = page ?? 1, MaxPage = (count / limit) + ((count % limit > 0) ? 1 : 0), }; if (paging.Page > paging.MaxPage) { paging.Page = paging.MaxPage; } return(paging); }
public async Task <IHttpActionResult> GetUsers(PagingViewModel model) { var result = await _repo.FindAllUser(model.PageNumber, model.PageSize, model.Keyword); var totalCount = (await _repo.FindAllUser(model.Keyword)).Count; var pagedSet = new PaginationSet <ApplicationUser> { Items = result, Page = model.PageNumber, TotalCount = totalCount, TotalPages = (int)Math.Ceiling((decimal)totalCount / model.PageNumber) }; return(Ok(pagedSet)); }
public IPagedList <TransactionViewModel> ViewTransactions(PagingViewModel pagingViewModel) { var query = _serviceTransactionService.GetQueryableServiceTransaction() .Join(_serviceService.GetQueryableService(), serviceTransaction => serviceTransaction.ServiceId, service => service.Id, (serviceTransaction, service) => new { ServiceTransaction = serviceTransaction, Service = service }) .Join(_customerService.GetQueryableCustomer(), serviceTransaction => serviceTransaction.ServiceTransaction.SupporterId, customer => customer.Id, (serviceTransaction, customer) => new TransactionViewModel { Name = customer.Name, SupporterEmail = customer.Email, Amount = Convert.ToDecimal(_dataProtector.Unprotect(serviceTransaction.ServiceTransaction.Amount)), Service = serviceTransaction.Service.Name }) .ToList(); return(new PagedList <TransactionViewModel>(query, pagingViewModel.PageIndex, pagingViewModel.PageSize)); }
public ActionResult Index(int page = 1) { var result = new PagingViewModel <TestViewModel>(); int totalItems = 0; result.Items = testService.GetTestsForPage((page - 1) * PageSize, PageSize, ref totalItems) .Select(x => x.ToMvcTest()); result.Paging = new Paging { PageNumber = page, PageSize = PageSize, TotalItems = totalItems }; if (Request.IsAjaxRequest()) { return(PartialView("ContentPartial", result)); } return(View(result)); }
public async Task <IHttpActionResult> GetAll(PagingViewModel model) { try { var cities = await _UnitOfWork.CityRepository .Filter(x => x.Name.ToLower() .Contains(model.Keyword.ToLower())) .OrderBy(x => x.Id).Skip(model.PageSize * model.PageNumber) .Take(model.PageSize).ToListAsync(); return(Ok(cities)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <IHttpActionResult> GetUserNotifications(PagingViewModel model) { try { string userName = User.Identity.GetUserName(); ApplicationUser u = await GetApplicationUser(userName); var notification = await _UnitOfWork.NotificationDeviceRepository .GetUserNotifications(u.Id, model.PageSize, model.PageNumber); return(Ok(notification)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public GpuNameCountsViewModel() { this._pagingVm = new PagingViewModel(() => this.PageIndex, () => this.PageSize); this.Search = new DelegateCommand(() => { this.PageIndex = 1; }); this.ClearKeyword = new DelegateCommand(() => { Keyword = string.Empty; }); this.PageSub = new DelegateCommand(() => { this.PageIndex -= 1; }); this.PageAdd = new DelegateCommand(() => { this.PageIndex += 1; }); this.Query(); }
public static IHtmlContent Paging(this IHtmlHelper helper, PagingForm form, Func <int, string> getPageFunc) { var vm = new PagingViewModel { Count = form.Count, Total = form.Total, GetUrl = getPageFunc, Offset = form.Offset }; vm.Current = form.Offset / form.Count; vm.LastPage = form.Total / form.Count; vm.Start = vm.Current - 2 > 0 ? vm.Current - 2 : 1; vm.Stop = vm.Current + 2 < vm.LastPage ? vm.Current + 2 : vm.LastPage; return(helper.Partial("~/Views/Shared/Paging.cshtml", vm)); }
// GET: Product public ViewResult ProductsList(int page = 1) { PagingViewModel pagingViewModel = new PagingViewModel { Products = productRepository.products .OrderBy(p => p.ProductId) .Skip((page - 1) * pageSize) .Take(pageSize), PagingInfo = new PagingInfo() { CurrentPage = page, ItemsPerPage = pageSize, TotalItems = productRepository.products.Count() } }; return(View(pagingViewModel)); }
public ActionResult Index(int page = 1) { var result = new PagingViewModel <FullArticleViewModel>(); int totalItems = 0; result.Items = _articleService.GetArticlesForPage((page - 1) * PageSize, PageSize, ref totalItems) .Select(x => _articleService.GetFullArticleEntity(x).ToMvcFullArticle()); result.Paging = new Paging { PageNumber = page, PageSize = PageSize, TotalItems = totalItems }; if (Request.IsAjaxRequest()) { return(PartialView("ContentPartial", result)); } return(View(result)); }
private PagingViewModel PreparePagingViewModel(int pageNumber, List <JobOffer> searchResult) { int totalPage, totalRecord, pageSize; pageSize = 4; totalRecord = searchResult.Count; totalPage = (totalRecord / pageSize) + ((totalRecord % pageSize) > 0 ? 1 : 0); searchResult = searchResult.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList(); PagingViewModel pagedOffers = new PagingViewModel { Offers = searchResult, TotalPage = totalPage }; return(pagedOffers); }
public PagingViewModel GetJobOffers(int pageNo = 1, int pageSize = 1) { int totalPage, totalRecord; totalRecord = _context.JobOffers.Count(); totalPage = (totalRecord / pageSize) + ((totalRecord % pageSize) > 0 ? 1 : 0); var record = (from u in _context.JobOffers orderby u.JobTitle select u).Skip((pageNo - 1) * pageSize).Take(pageSize).ToList(); PagingViewModel empData = new PagingViewModel { JobOffers = record, TotalPage = totalPage }; return(empData); }
public PagingViewModel GetUsers(int pageNo = 1, int pageSize = 4) { int totalPage, totalRecord; totalRecord = _context.User.Count(); totalPage = (totalRecord / pageSize) + ((totalRecord % pageSize) > 0 ? 1 : 0); var record = (from u in _context.User orderby u.Name, u.Surname select u).Skip((pageNo - 1) * pageSize).Take(pageSize).ToList(); PagingViewModel empData = new PagingViewModel { Users = record, TotalPage = totalPage }; return(empData); }
public ActionResult List(int page = 1) { var aos = _addressObjectService.ListByPage(page, PAGE_SIZE); var pageingInfo = new PagingViewModel { CurrentPage = page, TotalItems = _addressObjectService.List().Count, ItemsPerPage = PAGE_SIZE }; var list = new ListViewModel { AddressObjects = aos.Select(ao => _addressObjectMapper.Map(ao)), PagingInfo = pageingInfo }; return(View(list)); }
public ActionResult GetNewsByPage(int page) { var newsList = Context.GetConditionalNews(i => i.IsPublic == true); var paging = new PagingHelper().GetPageInfo(newsList.Count(), page, 5); var items = newsList.ToList().GetRange(paging.StartIndex, paging.Count).Select(i => new NewsModel(i)); var model = new PagingViewModel<NewsModel>(paging, items.ToList()); return View(); }