public IActionResult Index(int id = 1, string name = "") { int count = SourceManager.GetCount(name); int prev = id - 1; int next = id + 1; if (id <= 1) { prev = 1; } if (count <= id * 5) { next = id; } ViewBag.Title = "Home"; ViewBag.Name = name; ViewBag.Prev = prev; ViewBag.Next = next; ViewBag.ID = id; return(View(SourceManager.Get(id, 5, name))); }
public ActionResult Table(int page = 1, string filter = "") { SourceManager manager = new SourceManager(); ViewBag.Filter = filter; TempData["CurrentPage"] = page; TempData["PageCount"] = ((manager.GetCount() - 1) / _rowsPerPage) + 1; if (filter != "") { TempData["CurrentPage"] = page; TempData["PageCount"] = ((manager.GetCount(filter) - 1) / _rowsPerPage) + 1; var lista = manager.Get((page - 1) * _rowsPerPage, _rowsPerPage, filter); return(PartialView(lista)); } return(PartialView(manager.Get((page - 1) * _rowsPerPage, _rowsPerPage))); }
public IActionResult Index(string lastName) { // W przypadku podania pustego stringu do wyszukiwania wróć do trybu wyświetlania // wszystkich rekordów z paginacją if (string.IsNullOrEmpty(lastName)) { return(RedirectToActionPermanent("Index", new { page = 1 })); } List <PersonModel> people = new List <PersonModel>(); try { using SourceManager sourceManager = new SourceManager(); lastName = string.IsNullOrWhiteSpace(lastName) ? "%" : lastName.Replace('*', '%'); people = sourceManager.Get(1, int.MaxValue, lastName); } catch { TempData["Error"] = "Błąd bazy danych"; return(View("DataSourceErrorPage")); // wyświetl stronę błędu } // Żeby nie wyświetlać zbyt wielu kolumn, wyświetlana jest tylko data ostatniego zapisu rekordu // Jeśli brak daty aktualizacji => data aktualizacji = data utworzenia (tylko na potrzeby tego widoku) people.ForEach(p => { if (p.Updated == null) { p.Updated = p.Created; } }); return(View(people)); }
public IActionResult Index(int page = 1, string search = null) { //TODO Stworzyć formularz wyszukiwarkę osoby i przerzucić wyświetlenie osób na osobny widok int pagemax = 0; do { pagemax++; }while (SourceManager.Get(pagemax, 4).Any()); int pagemaxsearch = 0; do { pagemaxsearch++; }while (SourceManager.GetByName(search, pagemax, 4).Any()); ViewBag.Search = search; ViewBag.pagemax = pagemax; ViewBag.pagemaxsearch = pagemaxsearch; ViewBag.page = page; if (search != null) { return(View(SourceManager.GetByName(search, page, 4))); } else { return(View(SourceManager.Get(page, 4))); } }
public IActionResult List(int page = 1) { ViewBag.PersonId = page; ViewBag.Title = "List of all entries | The Phone Book"; ViewBag.Subtitle = "List of all entries"; ViewBag.List = "active"; return(View(SourceManager.Get(page, 6))); }
public IActionResult Index(int id = 1, string searchText = null) { // Pobranie ogólnej liczby osób int count = string.IsNullOrWhiteSpace(searchText) ? SourceManager.GetCount() : SourceManager.GetCount(searchText); // Przypisanie szukanego tekstu do ViewBag-a ViewBag.SearchText = searchText; // Dla mniej niż 10 osób - tylko 1 strona if (id <= 1 && (id * 10) >= count) { ViewBag.Previous = null; ViewBag.PreviousDis = "disabled"; ViewBag.Next = null; ViewBag.NextDis = "disabled"; ViewBag.Page = 1; } // Dla pierwszej strony else if (id <= 1) { ViewBag.Previous = null; ViewBag.PreviousDis = "disabled"; ViewBag.Next = 2; ViewBag.NextDis = ""; ViewBag.Page = id; } // Dla ostatniej strony else if ((id * 10) >= count) { ViewBag.Previous = id - 1; ViewBag.PreviousDis = ""; ViewBag.Next = null; ViewBag.NextDis = "disabled"; ViewBag.Page = id; } // Dla strony pomiędzy else { ViewBag.Previous = id - 1; ViewBag.PreviousDis = ""; ViewBag.Next = id + 1; ViewBag.NextDis = ""; ViewBag.Page = id; } // Zwrócenie modelu z listą osób List <PersonModel> list = string.IsNullOrWhiteSpace(searchText) ? SourceManager.Get(id, 10) : SourceManager.Get(id, 10, searchText); // Zwrócenie widoku return(View(list)); }
public IActionResult Index(int page = 1) { int records = _sourceManager.NumberOfRecords(); int pages = (int)Math.Ceiling((double)(records / RecordsPerPage)); ViewBag.Pages = pages; ViewBag.ActualPage = page; int skip = page == 1 ? 0 : (RecordsPerPage * page); var personsList = _sourceManager.Get(skip, RecordsPerPage); //IEnumerable<PersonModel> personsList = personListAll.Skip(skip).Take(RecordsPerPage); return(View(personsList)); }
public IActionResult Index(int page = 1) { ViewBag.AllRows = Math.Ceiling(SourceManager.NumberAllRows() / 3.0); ViewBag.page = page; List <PersonModel> persons = SourceManager.Get(page, 3, out int num); if (num != -1) { return(View(persons)); } else { ViewBag.Info = "no contacts"; return(View()); } }
public IActionResult Index(int page = 1, string filterLastName = "") { var repo = new SourceManager(); List <PersonModel> list = _repo.Get(); if (!String.IsNullOrWhiteSpace(filterLastName)) { list = list.Where(q => q.LastName.StartsWith(filterLastName)).ToList(); } var pageElements = 5; var pages = Math.Ceiling((decimal)list.Count() / pageElements); list = list.Skip((page - 1) * pageElements).Take(pageElements).ToList(); ViewBag.Page = page; ViewBag.Pages = pages; ViewBag.FilterLastName = filterLastName; return(View(list)); }
public IActionResult Index(int page = 1, int linesPerPage = 10, string filterLastName = "") { //var manager = new SourceManager(); var list = _manager.Get(1, 1); if (!string.IsNullOrWhiteSpace(filterLastName)) { list = list.Where(x => !string.IsNullOrEmpty(x.LastName) && x.LastName.ToLower().StartsWith(filterLastName.ToLower())).ToList(); } /*liczba wpisów na stronie*/ //int linesPerPage = 10; var numOfPages = (int)Math.Ceiling((decimal)list.Count / (decimal)linesPerPage); page = page <1 ? 1 : page> numOfPages ? numOfPages : page; ViewBag.NumberOfRows = list.Count; //ViewBag.CurrentPage = page; //ViewBag.TotalPages = numOfPages; ViewBag.FilterLastName = filterLastName; ViewBag.LinesPerPage = linesPerPage; list = list.Skip((page - 1) * linesPerPage).Take(linesPerPage).ToList(); var personViewModel = new PersonViewModel() { NumberOfRows = list.Count, CurrentPage = page, TotalPages = numOfPages, FilterLastName = filterLastName, LinesPerPage = linesPerPage, PersonList = list }; //return View(list); return(View(personViewModel)); }
public IActionResult Index(int page = 1) { int rowsPerPage = 15; List <PersonModel> people = new List <PersonModel>(); try { List <PageButtonModel> pageButtons = new List <PageButtonModel>(); // Lista z przyciskami paginacji using SourceManager sourceManager = new SourceManager(); int peopleCount = sourceManager.GetPeopleCount(); // Policz wszystkie rekordy int startRow = page == 1 ? 1 : (page - 1) * rowsPerPage + 1; people = sourceManager.Get(startRow, rowsPerPage, "%"); // Pobierz rekordy dla żądanej strony int pageCount = (int)Math.Ceiling(peopleCount / (double)rowsPerPage); for (int i = 1; i <= pageCount; ++i) { pageButtons.Add(new PageButtonModel { PageNumber = i }); } ViewBag.Pagination = pageButtons; } catch { TempData["Error"] = "Błąd bazy danych"; return(View("DataSourceErrorPage")); // wyświetl stronę błędu } // Żeby nie wyświetlać zbyt wielu kolumn, wyświetlana jest tylko data ostatniego zapisu rekordu // Jeśli brak daty aktualizacji => data aktualizacji = data utworzenia (tylko na potrzeby tego widoku) people.ForEach(p => { if (p.Updated == null) { p.Updated = p.Created; } }); return(View(people)); }
public ActionResult Index(string search = "", int page = 1) { ViewBag.page = page; return(View(SourceManager.Get(search, page))); }
// GET: /<controller>/ public IActionResult Index() { //TODO Stworzyć formularz wyszukiwarkę osoby i przerzucić wyświetlenie osób na osobny widok return(View(SourceManager.Get(0, 10))); }
public IActionResult Index() { return View(sourceManager.Get()); }
public IActionResult Index(int id = 1) { ViewBag.ID = id; return(View(SourceManager.Get(id, 5))); }
public IActionResult Index() { return(View(SourceManager.Get(1, 3))); }