Exemplo n.º 1
0
 //default page is number 1
 public async Task <IActionResult> Index(string txtSearch, int page = 1)
 {
     if (HttpContext.Session.GetString("ID") == null)
     {
         return(RedirectToAction("Login", "Admin"));
     }
     else
     {
         if (!string.IsNullOrEmpty(txtSearch))
         {
             dynamic querySearch = tourRepository.findTours(txtSearch);
             if (querySearch != null)
             {
                 //keep Search value
                 ViewBag.SearchValue = txtSearch;
                 return(View(await PagingList.CreateAsync(querySearch, 10, page)));
             }
             else
             {
                 ViewBag.Empty("Not Found.");
                 return(View());
             }
         }
         //get Tour list
         dynamic query = tourRepository.GetAllTours;
         return(View(await PagingList.CreateAsync(query, 10, page)));
     }
 }