public List <ArtefactDto> GetFiltered(ArtefactFilter filter) { IQueryable <Artefact> artefacts = Db.Artefacts; if (filter.categoryId.HasValue) { artefacts = artefacts.Where(m => m.ArtefactCategory.Id == filter.categoryId.Value); } if (filter.zoneId.HasValue) { artefacts = artefacts.Where(m => m.Zone.Id == filter.zoneId.Value); } if (filter.beaconId.HasValue) { artefacts = artefacts.Where(m => m.Beacon.Id == filter.beaconId.Value); } if (filter.isDeleted.HasValue) { artefacts = artefacts.Where(m => m.IsDeleted == filter.isDeleted.Value); } return(Mapper.Map <List <ArtefactDto> >(artefacts.OrderBy(m => m.ModifiedDate).Skip(filter.pageSize * filter.page).Take(filter.pageSize))); }
ArtefactDto GetArtefact() { ArtefactFilter filter = new ArtefactFilter() { isDeleted = false, numPerPage = 1, pageNumber = 0 }; var artefacts = _controller.GetFiltered(filter); if (artefacts != null && artefacts.Any()) { return(artefacts.First()); } else { //Create a new artefact for testing return(CreateTestArtefact()); } }