public ActionResult ArchiveTripIndex(string searchString, int?page = 1)
 {
     try
     {
         if (searchString != null)
         {
             page = 1;
             ViewBag.SearchData = searchString;
         }
         int pageSize   = 20;
         int pageNumber = (page ?? 1);
         ArchiveTripCommonDTO archivedTrips        = _archiveTripService.Retrieve(page, searchString);
         IEnumerable <ArchiveTripViewModel> models = null;
         ViewBag.Page    = page;
         ViewBag.MaxPage = (archivedTrips.ItemCount / pageSize) - (archivedTrips.ItemCount % pageSize == 0 ? 1 : 0);
         if (archivedTrips != null)
         {
             models = Mapper.Map <IEnumerable <ArchiveTripViewModel> >(archivedTrips.ArchivedTrips);
         }
         return(View(models));
     }
     catch (Exception ex)
     {
         return(Json(ex.Message));
     }
 }
        public ArchiveTripCommonDTO Retrieve(int?pageNumber, string voucherNumber)
        {
            try
            {
                SPRetrieveArchiveTrip parameters = new SPRetrieveArchiveTrip();
                parameters.VoucherNumber = voucherNumber;
                parameters.PageNumber    = pageNumber;

                using (var connection = GetConnection())
                {
                    var resultSet = connection.QueryMultiple(sql: parameters.GetName(), param: parameters, commandType: CommandType.StoredProcedure);

                    ArchiveTripCommonDTO archivedTrip = new ArchiveTripCommonDTO();
                    archivedTrip.ArchivedTrips = resultSet.Read <ArchiveTrip>();
                    archivedTrip.ItemCount     = resultSet.Read <int>().Single();
                    return(archivedTrip);
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }