Beispiel #1
0
 public IActionResult Index(string dataTimKiem, string loaiTimKiem, int PageNumber = 1)
 {
     ViewBag.Name = HttpContext.Session.GetString("Ten");
     if (HttpContext.Session.GetString("VaiTro") == "NguoiQuanTri")
     {
         if (dataTimKiem == null)
         {
             NguoiDungViewModel model = iNguoiDungService.GetNguoiDungs();
             ViewBag.TotalPages  = Math.Ceiling(model.NguoiDungs.Count() / 5.0);
             ViewBag.dataTimKiem = dataTimKiem;
             ViewBag.loaiTimKiem = loaiTimKiem;
             var user = model.NguoiDungs.Skip((PageNumber - 1) * 5).Take(5).ToList();
             return(View(user));
         }
         else
         {
             var model = iNguoiDungService.GetSearchTenNguoiDung(dataTimKiem, loaiTimKiem);
             ViewBag.TotalPages  = Math.Ceiling(model.Count() / 5.0);
             ViewBag.dataTimKiem = dataTimKiem;
             ViewBag.loaiTimKiem = loaiTimKiem;
             if (Math.Ceiling(model.Count() / 5.0) <= PageNumber - 1)
             {
                 var user = model.Skip((1 - 1) * 5).Take(5).ToList();
                 return(View(user));
             }
             else
             {
                 var user = model.Skip((PageNumber - 1) * 5).Take(5).ToList();
                 return(View(user));
             }
         }
     }
     return(RedirectToAction("Login"));
 }