public PartialViewResult _ListPhotos() { var photos = new PagedDataList<ManagePhotoModel> { PagedEntity = unitOfWork.PhotoRepository.Get().OrderBy(x => x.PhotoID).Select(p => new ManagePhotoModel { PhotoID = p.PhotoID, Description = p.Description, Title = p.Title, AlbumName = p.Album.Name, ThumpnailPath = p.ThumbnailPath }).Take(ServerConstants.PAGE_SIZE).ToList(), NumberOfPages = Convert.ToInt32(Math.Ceiling((double)unitOfWork.PhotoRepository.Get().Count() / ServerConstants.PAGE_SIZE)) }; ViewBag.Albums = new SelectList(unitOfWork.AlbumRepository.Get(), "AlbumID", "Name"); ViewBag.NumberOfPages = photos.NumberOfPages; return PartialView(photos); }
public async Task <PagedDataList <EmployeeModel> > Get(FilterParams filterParams) { var employees = this.dataContext.Employees.AsQueryable(); if (!string.IsNullOrEmpty(filterParams.LastNameFilter)) { employees = employees.Where(x => x.LastName.ToLower() == filterParams.LastNameFilter.ToLower()); } if (!string.IsNullOrEmpty(filterParams.TaxNumberFilter)) { employees = employees.Where(x => x.TaxNumber.ToLower() == filterParams.TaxNumberFilter.ToLower()); } if (!string.IsNullOrEmpty(filterParams.WorkingPositionFilter)) { employees = employees.Where(x => x.WorkingPosition.ToLower() == filterParams.WorkingPositionFilter.ToLower()); } return(await PagedDataList <EmployeeModel> .CreateAsync(employees, filterParams.PageNumber, filterParams.PageSize)); }
public PagedDataList<PersonalSettingViewModel> PersonalSettingSearch(PersonalSettingSearchViewModel model) { EMVehicleService service = new EMVehicleService(); PositionService positionServ = new PositionService(); try { //int rowCount = 0; //IList<EMVehicle> list = service.Select(model.userCode,model.vehilceLikeStr,true,model.ltGpsTypeID, model.rowIndex,model.pageSize, out rowCount); //IList<Guid> ltVehicleCode_Paging = list.Select(p => p.VehicleCode).ToList(); //IList<EGPSCurrentInfo> ltCurrentInfo = positionServ.GetCurrentInfoList(ltVehicleCode_Paging); //IDictionary<Guid, DateTime> CurrentInfoDic = ltCurrentInfo.ToDictionary(p => p.VehicleCode, p => p.ReportTime); //IList<EMOpenGPSInfo> listEntity = null; /////获取开启GPSCode的返回数据 //if (model.OpenGPSCodeList != null && model.OpenGPSCodeList.Count > 0) //{ // EMOpenGPSInfoService openGPSservice = new EMOpenGPSInfoService(); // listEntity = openGPSservice.GetList(list.Select(p => p.GPSCode).ToList(), 1); //} //if (list != null && list.Count > 0 && rowCount > 0) //{ // List<PersonalSettingViewModel> newList = new List<PersonalSettingViewModel>(); // PagedDataList<PersonalSettingViewModel> pdl = new PagedDataList<PersonalSettingViewModel>(); // foreach (EMVehicle emVehicle in list) // { // PersonalSettingViewModel psvModel = new PersonalSettingViewModel(); // psvModel.GpsCode = emVehicle.GPSCode; // psvModel.GpsTypeID = emVehicle.GPSTypeID; // psvModel.VehicleInfo = emVehicle.LicenceNumber; // psvModel.VehicleCode = emVehicle.VehicleCode; // if (CurrentInfoDic.ContainsKey(emVehicle.VehicleCode)) // { // TimeSpan timeSpan = DateTime.Now.Subtract(CurrentInfoDic[emVehicle.VehicleCode]); // psvModel.IsEnable = !(timeSpan.TotalMinutes > Param_OffLineTime); // } // else // psvModel.IsEnable = false; // if (listEntity != null && listEntity.Count > 0) // { // foreach (EMOpenGPSInfo gpsInfo in listEntity) // { // if (psvModel.GpsCode == gpsInfo.GPSCode) // { // psvModel.OpenResultContent = gpsInfo.Results; // psvModel.LastSetTime = gpsInfo.LastSetTime; // } // } // } // newList.Add(psvModel); // } // pdl.Datas = newList; // pdl.RowCount = rowCount; // return pdl; //代码优化 int rowCount = 0; VehicleDAL vDal = new VehicleDAL(); List<EmPersonalSetting> pelist = service.NewSelect(model.userCode, model.vehilceLikeStr, true, model.ltGpsTypeID, model.rowIndex, model.pageSize, out rowCount, 1); if (pelist != null && pelist.Count > 0 && rowCount > 0) { PagedDataList<PersonalSettingViewModel> pdl = new PagedDataList<PersonalSettingViewModel>(); pdl.Datas = GetPerSettingViewModel(pelist); pdl.RowCount = rowCount; return pdl; } return null; } catch (Exception ex) { Logger.Error(ex.Message); return null; } }
public PartialViewResult GetNextResult(int currentPageNumber) { var photos = new PagedDataList<ManagePhotoModel> { PagedEntity = unitOfWork.PhotoRepository.Get(orderby: q => q.OrderBy(d => d.PhotoID)).Select(p => new ManagePhotoModel { PhotoID = p.PhotoID, Description = p.Description, Title = p.Title, AlbumName = p.Album.Name, ThumpnailPath = p.ThumbnailPath }).Skip(ServerConstants.PAGE_SIZE * (currentPageNumber - 1)).Take(ServerConstants.PAGE_SIZE).ToList(), NumberOfPages = Convert.ToInt32(Math.Ceiling((double)unitOfWork.PhotoRepository.Get().Count() / ServerConstants.PAGE_SIZE)), CurrentPage = currentPageNumber }; ViewBag.NumberOfPages = photos.NumberOfPages; return PartialView("_ListPhotos", photos); }
public JsonResult GetNewCarList(string tenantCode, string LicenceNumber, string SIMNo, string DeviceNo, int rows, int pageSize) { //代码优化 int iRowCount; int pageIndex = (rows - 1) * pageSize; List<VehicleManager> vlist = new List<VehicleManager>(); VehicleManagerWCFService vbll = new VehicleManagerWCFService(); vlist = vbll.GetCarList(tenantCode, LicenceNumber, SIMNo, DeviceNo, pageIndex, pageSize, out iRowCount); PagedDataList<VehicleManager> list = new PagedDataList<VehicleManager>(vlist, iRowCount); return Json(list, JsonRequestBehavior.AllowGet); }
public void Init() { var employees = new List <EmployeeModel>() { new EmployeeModel { Id = 1, Birth = DateTime.Now.AddYears(-10), FirstName = "John", LastName = "Doe", Salary = 1000, TaxNumber = "1234", WorkingPosition = "Developer" }, new EmployeeModel { Id = 2, Birth = DateTime.Now.AddYears(-20), FirstName = "Edward", LastName = "Kovalsky", Salary = 2000, TaxNumber = "0987", WorkingPosition = "CEO" } }; var pagedList = new PagedDataList <EmployeeModel>(employees, 0, 0, 0); var employeesForList = new List <EmployeeForListDto>() { new EmployeeForListDto { Id = 1, Age = 10, FirstName = "John", LastName = "Doe", Salary = 1000, TaxNumber = "1234", WorkingPosition = "Developer" }, new EmployeeForListDto { Id = 2, Age = 20, FirstName = "Edward", LastName = "Kovalsky", Salary = 2000, TaxNumber = "0987", WorkingPosition = "CEO" } }; var employee = new EmployeeModel { Id = 1, Birth = DateTime.Now.AddYears(-10), FirstName = "John", LastName = "Doe", Salary = 1000, TaxNumber = "1234", WorkingPosition = "Developer" }; var employeeForList = new EmployeeForListDto { Id = 1, Age = 10, FirstName = "John", LastName = "Doe", Salary = 1000, TaxNumber = "1234", WorkingPosition = "Developer" }; var eRMock = new Mock <IEmployeesRepository>(MockBehavior.Strict); eRMock.Setup(m => m.Get(null)).Returns(Task.FromResult(pagedList)); eRMock.Setup(m => m.Get(1)).Returns(Task.FromResult(employee)); eRMock.Setup(m => m.Save()).Returns(Task.FromResult(true)); eRMock.Setup(m => m.Update(It.IsAny <EmployeeModel>(), It.IsAny <EmployeeModel>())); eRMock.Setup(m => m.Add(It.IsAny <EmployeeModel>())); eRMock.Setup(m => m.Delete(It.IsAny <EmployeeModel>())); var mapMock = new Mock <IMapper>(MockBehavior.Strict); mapMock.Setup(m => m.Map <IEnumerable <EmployeeForListDto> >(It.IsAny <EmployeeModel>())).Returns(employeesForList); mapMock.Setup(m => m.Map <EmployeeForListDto>(It.IsAny <EmployeeModel>())).Returns(employeeForList); mapMock.Setup(m => m.Map <IEnumerable <EmployeeForListDto> >(It.IsAny <PagedDataList <EmployeeModel> >())).Returns(employeesForList); this.employeesRepository = eRMock; this.mapper = mapMock; }