Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 public IEnumerable<BaseBeek> SearchBeek(BeekSearchbag bag)
 {
     return ParseToBeek(XDocument.Load(CreateRequest(bag).GetResponse().GetResponseStream()));
 }
Exemplo n.º 4
0
 public IEnumerable<BaseBeek> SearchBeek(BeekSearchbag bag, int skip, int take)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public IEnumerable<BaseBeek> SearchBeek(BeekSearchbag bag, int skip, int take)
 {
     return SearchBeek(bag).Skip(skip).Take(take);
 }