-
-
Save jfromaniello/478757 to your computer and use it in GitHub Desktop.
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
using System; | |
using BrokersWeb.Search.Domain; | |
using NHibernate; | |
using NHibernate.Criterion; | |
using System.Linq; | |
namespace BrokersWeb.Search.Data{ | |
public class NhSearchListingQuery : ISearchListingQuery{ | |
public NhSearchListingQuery(ISessionFactory factory){ | |
ISession session = factory.GetCurrentSession(); | |
} | |
public IQueryOver<Listing, Listing> Criteria { get; set; } | |
#region ISearchListingQuery Members | |
public string StateCode{ get; set; } | |
public int? ProductId{get; set;} | |
public int? AffiliateId{get; set;} | |
public int? ExcludedDomain{get;set;} | |
public int[] ClickedItems {get;set} | |
public int[] ExcludeCategories {get;set;} | |
public IPagedList<Listing> Query(int limit, int page){ | |
var query = session.Query<Listing>(); | |
if (!string.IsNullOrEmpty(value)) | |
query = query.Where(l => l.StateCode == StateCode); | |
if(ProductId.HasValue) | |
query = query.Where(l => l.ProductId == ProductId.Value); | |
if(AffiliateId.HasValue) | |
query = query.Where(l => !l.Domain.Advertiser.ExcludedAffiliates.Any(a => a.Value == AffiliateId); | |
if(ExcludedDomain.HasValue) | |
query = query.Where(l => l.Domain.Id != ExcludedDomain.Value) | |
if(ExcludedCategories != null && ExcludedCategories.Any()) | |
query = query.Where(l => !l.Domain.Advertiser.Categories.Any(c => c.Id == ExcludedCategories)); | |
return ..........query) | |
} | |
#endregion | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment