コード例 #1
0
 public ActionResult GetNextCars(string make, string model, string term, int?page, int pageSize = 10)
 {
     try
     {
         var pageIndex = page - 1 ?? 0;
         CarGridViewModel returnModel = new CarGridViewModel()
         {
             Cars  = PagedListHelpers.GetNextCars(make, model, term, pageIndex, pageSize),
             Make  = make,
             Model = model,
             Term  = term
         };
         if (returnModel != null)
         {
             return(PartialView("_CarsGrid", returnModel));
         }
         else
         {
             throw new Exception("The 'CarGridViewModel' object containing the 'Car' entity result collection is null.", new NoNullAllowedException());
         }
     }
     catch (Exception ex)
     {
         return(View("Error", new HandleErrorInfo(ex, "Cars", "Index")));
     }
 }
コード例 #2
0
 public ActionResult SearchCars(string term)
 {
     try
     {
         CarGridViewModel model = new CarGridViewModel()
         {
             Cars = PagedListHelpers.GetNextCars(null, null, term, 0, 10),
             Term = term
         };
         if (model != null)
         {
             return(PartialView("_CarsGrid", model));
         }
         else
         {
             throw new Exception("The 'CarGridViewModel' object containing the 'Car' entity result collection is null.", new NoNullAllowedException());
         }
     }
     catch (Exception ex)
     {
         return(View("Error", new HandleErrorInfo(ex, "Cars", "Index")));
     }
 }