public IEnumerable<BaseBeek> SearchBeek(BeekSearchbag bag) { if(!bag.HasValues()) { return new List<BaseBeek>(); } var q = beekRepository.GetBeek(); if(bag.BeekId.HasValue) { q = q.Where(b => b.Id.Equals(bag.BeekId)); } if (!string.IsNullOrEmpty(bag.BeekTitleStartsWith)) { q = q.Where(b => b.Title.StartsWith(bag.BeekTitleStartsWith, StringComparison.InvariantCultureIgnoreCase)); } if (!string.IsNullOrEmpty(bag.BeekTitleEndsWith)) { q = q.Where(b => b.Title.EndsWith(bag.BeekTitleEndsWith, StringComparison.InvariantCultureIgnoreCase)); } if(!string.IsNullOrEmpty(bag.BeekTitleContains)) { q = q.Where(b => b.Title.Contains(bag.BeekTitleContains, StringComparison.InvariantCultureIgnoreCase)); } if(!string.IsNullOrEmpty(bag.IsbnContains)) { q = q.Where(b => b.Isbn.Contains(bag.IsbnContains, StringComparison.InvariantCultureIgnoreCase)); } if (!string.IsNullOrEmpty(bag.IsbnStartsWith)) { q = q.Where(b => b.Isbn.StartsWith(bag.IsbnContains, StringComparison.InvariantCultureIgnoreCase)); } if (!string.IsNullOrEmpty(bag.IsbnEndsWith)) { q = q.Where(b => b.Isbn.EndsWith(bag.IsbnContains, StringComparison.InvariantCultureIgnoreCase)); } if(!string.IsNullOrEmpty(bag.AuthorNameContains)) { q = q.Where(b => b.GetInvolvedUsersForContribution(Contributions.Writer).Any(u=>u.Name.Contains(bag.AuthorNameContains, StringComparison.InvariantCultureIgnoreCase))); } if (!string.IsNullOrEmpty(bag.AuthorNameEndsWith)) { q = q.Where(b => b.GetInvolvedUsersForContribution(Contributions.Writer).Any(u => u.Name.EndsWith(bag.AuthorNameEndsWith, StringComparison.InvariantCultureIgnoreCase))); } if (!string.IsNullOrEmpty(bag.AuthorNameStartsWith)) { q = q.Where(b => b.GetInvolvedUsersForContribution(Contributions.Writer).Any(u => u.Name.StartsWith(bag.AuthorNameStartsWith, StringComparison.InvariantCultureIgnoreCase))); } return q.AsEnumerable(); }
private WebRequest CreateRequest(BeekSearchbag bag) { string request; if (!string.IsNullOrWhiteSpace(bag.BeekTitleContains)) { request = string.Format(baseRequestUrl, "title", HttpUtility.UrlEncode(bag.BeekTitleContains)); } else { throw new NotImplementedException(); } return WebRequest.Create(request); }
public IEnumerable<BaseBeek> SearchBeek(BeekSearchbag bag) { return ParseToBeek(XDocument.Load(CreateRequest(bag).GetResponse().GetResponseStream())); }
public IEnumerable<BaseBeek> SearchBeek(BeekSearchbag bag, int skip, int take) { throw new NotImplementedException(); }
public IEnumerable<BaseBeek> SearchBeek(BeekSearchbag bag, int skip, int take) { return SearchBeek(bag).Skip(skip).Take(take); }