/// <summary> /// View all jobs /// </summary> /// <returns>View Home/Index</returns> public async Task <IActionResult> Index(string sortOrder, string currentFilter, string searchString, int?pageNumber) { try { int pageSize = 5; ViewData["CurrentSort"] = sortOrder; ViewData["NameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "Name_desc" : ""; ViewData["PriceSortParm"] = sortOrder == "Price" ? "Price_desc" : "Price"; if (searchString != null) { pageNumber = 1; } else { searchString = currentFilter; } ViewData["CurrentFilter"] = searchString; var list = await _jobService.GetAllSorting(sortOrder); var search = _jobService.Search(searchString, list); var map = _mapper.Map <IEnumerable <JobDTO>, IEnumerable <JobViewModel> > (search); var view = await PaginatedListModel <JobViewModel> .Create(map.AsQueryable(), pageNumber ?? 1, pageSize); return(View(view)); } catch { throw; } }
public async Task <IActionResult> IcerikList(int pageNumber = 1) { ViewBag.icerikList = true; var list = await _ıcerikService.GetAllIcerik(); return(View(await PaginatedListModel <Icerik> .CreateAsync(list, pageNumber, 10))); }
public async Task <IActionResult> KonuListbyid(int id, int pageNumber = 1) { ViewBag.icerikList = false; var list = await _ıcerikService.GetIcerikByKonuId(id); return(View("IcerikList", await PaginatedListModel <Icerik> .CreateAsync(list, pageNumber, 10))); }
public PaginatedListModel <ExpenseGetModel> GetAll(int page, DateTime?from = null, DateTime?to = null, Models.Type?type = null) { IQueryable <Expense> result = context .Expenses .OrderBy(e => e.Id) .Include(x => x.Comments); PaginatedListModel <ExpenseGetModel> paginatedResult = new PaginatedListModel <ExpenseGetModel>(); paginatedResult.CurrentPage = page; if (from != null) { result = result.Where(e => e.Date >= from); } if (to != null) { result = result.Where(e => e.Date <= to); } if (type != null) { result = result.Where(e => e.Type == type); } paginatedResult.NumberOfPages = (result.Count() - 1) / PaginatedListModel <ExpenseGetModel> .EntriesPerPage + 1; result = result .Skip((page - 1) * PaginatedListModel <ExpenseGetModel> .EntriesPerPage) .Take(PaginatedListModel <ExpenseGetModel> .EntriesPerPage); paginatedResult.Entries = result.Select(e => ExpenseGetModel.FromExpense(e)).ToList(); return(paginatedResult); }
public async Task <IViewComponentResult> InvokeAsync(string Userid, int pageNumber, bool MyPage = false) { ViewBag.MyPage = MyPage; ViewBag.userid = Userid; var list = await _icerikService.GetIcerikByUserId(Userid); return(View(await PaginatedListModel <Icerik> .CreateAsync(list, pageNumber, 5))); }
public async Task <IActionResult> List(int page = 1, Guid?category = null, string searchQuery = "") { if (page < 1) { return(NotFound()); } ViewData["SelectedCategoryId"] = category; ViewData["SearchQuery"] = searchQuery; var model = new PaginatedListModel <ProgrammingTask> { Pagination = new PaginationInfo { CurrentPage = page, ItemsPerPage = ItemsPerPage } }; var databaseQuery = ( from programmingTask in _databaseContext.ProgrammingTasks where programmingTask.VisibleInFreeMode where EF.Functions.Like(programmingTask.Title, $"%{searchQuery}%") where (category == null || programmingTask.CategoryId == category) select programmingTask ) .OrderBy(t => t.Difficulty) .ThenBy(t => t.CategoryId) .ThenBy(t => t.Title) .AsNoTracking(); model.Pagination.TotalItems = await databaseQuery.CountAsync(); if (model.Pagination.TotalItems <= 0 && page > 1) { return(NotFound()); } if (model.Pagination.TotalItems > 0 && model.Pagination.TotalPages < page) { return(NotFound()); } model.ItemsList = await databaseQuery .Skip(model.Pagination.PreviousItemsCount).Take(ItemsPerPage) .Select(t => new ProgrammingTask { Id = t.Id, Title = t.Title, Difficulty = t.Difficulty, CategoryId = t.CategoryId }).ToListAsync(); return(View(ViewsDirectoryPath + "List.cshtml", model)); }
public ActionResult Index(int id = 1, int pageSize = 6) { var model = new PaginatedListModel<ProductModel>(); var total = 0; model.Items = this.service.GetProducts(pageSize, id - 1, out total).Select(this.mapper.Map); model.Total = total; model.Page = id; model.PageSize = pageSize; return View(model); }
public ActionResult Index(int id = 1, int pageSize = 6) { var model = new PaginatedListModel <ProductModel>(); var total = 0; model.Items = this.service.GetProducts(pageSize, id - 1, out total).Select(this.mapper.Map); model.Total = total; model.Page = id; model.PageSize = pageSize; return(View(model)); }
public ActionResult Search(int id = 1, int pageSize = 9, string category = null, string word = null) { ViewBag.Searched = word; ViewBag.Category = category; var model = new PaginatedListModel<ProductModel>(); var total = 0; model.Items = this.service.SearchProducts(category, word, pageSize, id - 1, out total).Select(this.mapper.Map); model.Total = total; model.Page = id; model.PageSize = pageSize; return View("Index", model); }
public ActionResult Search(int id = 1, int pageSize = 9, string category = null, string word = null) { ViewBag.Searched = word; ViewBag.Category = category; var model = new PaginatedListModel <ProductModel>(); var total = 0; model.Items = this.service.SearchProducts(category, word, pageSize, id - 1, out total).Select(this.mapper.Map); model.Total = total; model.Page = id; model.PageSize = pageSize; return(View("Index", model)); }
public ActionResult UserList(int id = 1, int pageSize = 10) { var model = new PaginatedListModel <UserListItemModel>(); var total = 0; model.Items = this.userService.GetAllUsers(pageSize, id - 1, out total).Select(u => new UserListItemModel { Id = u.Id, Email = u.UserName, FullName = string.Format("{0} {1}", u.Name, u.LastName), Roles = "" }); model.Total = total; model.Page = id; model.PageSize = pageSize; return(View(model)); }
public async Task <IViewComponentResult> InvokeAsync(int?KonuId, int pageNumber) { if (KonuId.HasValue) { //var listwithid = _icerikRepository.GetirİcerikIdile((int)KonuId); var listwithid = await _icerikService.GetIcerikByKonuId((int)KonuId); return(View(await PaginatedListModel <Icerik> .CreateAsync(listwithid, pageNumber, 5))); ////return View(resultidile); } //var list = _icerikRepository.GetirİcerikHepsi();//Await var list = await _icerikService.GetAllIcerik(); return(View(await PaginatedListModel <Icerik> .CreateAsync(list, pageNumber, 5))); //return View(result); }
public PaginatedListModel <CommentGetModel> GetAll(string filter, int page) { IQueryable <Comment> result = context .Comments .Where(c => string.IsNullOrEmpty(filter) || c.Text.Contains(filter)) .OrderBy(c => c.Id) .Include(c => c.Expense); PaginatedListModel <CommentGetModel> paginatedResult = new PaginatedListModel <CommentGetModel>(); paginatedResult.CurrentPage = page; paginatedResult.NumberOfPages = (result.Count() - 1) / PaginatedListModel <CommentGetModel> .EntriesPerPage + 1; result = result .Skip((page - 1) * PaginatedListModel <CommentGetModel> .EntriesPerPage) .Take(PaginatedListModel <CommentGetModel> .EntriesPerPage); paginatedResult.Entries = result.Select(f => CommentGetModel.FromComment(f)).ToList(); return(paginatedResult); }
public ActionResult List(PaginatedListModel<PeripheralDevice> model) { model.Page = 1; return RedirectToAction("List", model); }
public ActionResult List(PaginatedListModel<MembershipRoleModel> model, FormCollection collection) { model.Page = 1; return RedirectToAction("List", model); }
// GET: Invoices public async Task <IActionResult> Index(string sortBy, string currentFilter, string search, int?page) { ViewData["IdSortParm"] = string.IsNullOrEmpty(sortBy) ? "id_desc" : sortBy == "id" ? "id_desc" : "id"; ViewData["CountSortParm"] = sortBy == "count" ? "count_desc" : "count"; ViewData["DateSortParm"] = sortBy == "date" ? "date_desc" : "date"; ViewData["SearchFilter"] = search; if (!string.IsNullOrEmpty(search)) { page = 1; } else { search = currentFilter; } var invoices = from x in _context.Invoices select x; if (!string.IsNullOrEmpty(search)) { if (int.TryParse(search, out int id)) { invoices = invoices.Where(x => x.InvoiceId == id); } else { invoices = invoices.Where(x => x.Stock.Name.ToLower().Contains(search.ToLower()) || x.Client.Name.ToLower().Contains(search.ToLower())); } } switch (sortBy) { case "id": invoices = invoices.OrderBy(x => x.InvoiceId); break; case "id_desc": invoices = invoices.OrderByDescending(x => x.InvoiceId); break; case "count": invoices = invoices.OrderBy(s => s.Count); break; case "count_desc": invoices = invoices.OrderByDescending(s => s.Count); break; case "date": invoices = invoices.OrderBy(s => s.CreateDateTime); break; case "date_desc": invoices = invoices.OrderByDescending(s => s.CreateDateTime); break; default: invoices = invoices.OrderByDescending(s => s.InvoiceId); break; } int pageSize = 10; var results = invoices .Include(x => x.Client) .Include(x => x.Stock) .AsNoTracking(); return(View(await PaginatedListModel <Invoice> .CreateAsync(results, page ?? 1, pageSize))); }
public async Task <IActionResult> List(int page = 1, Guid?groupId = null, string institutionName = "", string searchQuery = "") { if (page < 1) { return(NotFound()); } ViewData["SpecifiedUsersGroupId"] = groupId; ViewData["SpecifiedInstitutionName"] = institutionName; ViewData["SpecifiedSearchQuery"] = searchQuery; var model = new PaginatedListModel <UsersListItemModel> { Pagination = new PaginationInfo { CurrentPage = page, ItemsPerPage = ItemsPerPage } }; var query = ( from user in _databaseContext.Users // Search queries where (groupId == null || user.UserGroupId == groupId) where (searchQuery == null || searchQuery.Length == 0 || EF.Functions.Like(user.FullName, $"%{searchQuery}%")) where (institutionName == null || institutionName.Length == 0 || EF.Functions.Like(user.InstitutionName, $"%{institutionName}%")) // Left join with testing applications join application in _databaseContext.TestingApplications on user.Id equals application.AuthorId into applications from application in applications .Where(a => a.CompetitionId == null) .Where(a => a.Status == TestingApplication.ApplicationStatus.Verified) .Where(a => a.TestingResults.SolutionAdjudgement != TestingApplication.ApplicationTestingResults .SolutionAdjudgementType.ZeroSolution) .Where(a => a.TestingType == TestingApplication.ApplicationTestingType.ReleaseMode) .DefaultIfEmpty() // Select joined data select new { user.Id, user.Type, user.UserGroupId, user.FullName, user.InstitutionName, application.TestingResults.GivenDifficulty } ).GroupBy(g => new { g.Id, g.Type, g.UserGroupId, g.FullName, g.InstitutionName }) .Select(s => new UsersListItemModel { Id = s.Key.Id, Type = s.Key.Type, UserGroupId = s.Key.UserGroupId, FullName = s.Key.FullName, InstitutionName = s.Key.InstitutionName, Rating = s.Sum(sum => sum.GivenDifficulty) }) .OrderByDescending(order => order.Rating) .ThenBy(order => order.FullName) .AsNoTracking(); model.ItemsList = await query .Skip(model.Pagination.PreviousItemsCount) .Take(ItemsPerPage).ToListAsync(); model.Pagination.TotalItems = await query.CountAsync(); if (model.Pagination.TotalItems <= 0 && page > 1) { return(NotFound()); } if (model.Pagination.TotalItems > 0 && model.Pagination.TotalPages < page) { return(NotFound()); } return(View(ViewsDirectoryPath + "List.cshtml", model)); }
public async Task <IActionResult> GetPaginated(PaginatedListModel query) { var results = await templatesService.GetPagedResults(query.Language, query.ContinuationToken); return(Ok(results)); }
public ActionResult List(PaginatedListModel<DeviceExtendedModel> model) { model.Page = 1; return RedirectToAction("List", model); }
public ActionResult List(PaginatedListModel<Licence> model) { model.Page = 1; return RedirectToAction("List", model); }
public ActionResult UserList(int id = 1, int pageSize = 10) { var model = new PaginatedListModel<UserListItemModel>(); var total = 0; model.Items = this.userService.GetAllUsers(pageSize, id - 1, out total).Select(u => new UserListItemModel { Id = u.Id, Email = u.UserName, FullName = string.Format("{0} {1}", u.Name, u.LastName), Roles = "" }); model.Total = total; model.Page = id; model.PageSize = pageSize; return View(model); }
public ActionResult List(PaginatedListModel<PersonSectionModel> model, FormCollection collection) { model.Page = 1; return RedirectToAction("List", model); }