Created
February 3, 2019 16:16
-
-
Save jamesmundy/8b7ca0de09188c6c177b34eb1ef0455b to your computer and use it in GitHub Desktop.
My old code for searching my table of boats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Task<PagedList<BoatDto>> Find(BoatCriteria criteria) | |
{ | |
return Adapter.Connect() | |
.CallAsync(async provider => | |
{ | |
var hasFilter = !string.IsNullOrWhiteSpace(criteria.Filter); | |
criteria.Filter = criteria.Filter?.ToLower(); | |
return await provider.Boats() | |
.Where(b => !hasFilter || b.Name.ToLower().Contains(criteria.Filter) | |
|| b.SailNumber.ToLower().Contains(criteria.Filter) | |
|| b.Model.ToLower().Contains(criteria.Filter) | |
|| b.Make.ToLower().Contains(criteria.Filter)) | |
.Select(BoatMappings.Select()) | |
.OrderBy(b => b.Name) | |
.ToPagedListAsync(c => c, criteria); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment