public IEnumerable <InitialCoinOffering> Get(InitialCoinOfferingSource initialCoinOfferingSource) { using (var context = new DatabaseContext()) { context.Configuration.AutoDetectChangesEnabled = false; context.Configuration.LazyLoadingEnabled = false; if (context.InitialCoinOfferingDbSet == null) { return(new List <InitialCoinOffering>()); } return(context.InitialCoinOfferingDbSet.Where(GetFilterExpression(initialCoinOfferingSource)).ToList()); } }
private static Expression <Func <InitialCoinOffering, bool> > GetFilterExpression(InitialCoinOfferingSource initialCoinOfferingSource) { Expression <Func <InitialCoinOffering, bool> > filterExpression; //temporary search for medium and linked in if (initialCoinOfferingSource == InitialCoinOfferingSource.Medium) { filterExpression = x => !x.IsVerified && (x.InitialCoinOfferingSourceId == (int)InitialCoinOfferingSource.Medium || x.InitialCoinOfferingSourceId == (int)InitialCoinOfferingSource.LinkedIn); } else { filterExpression = x => !x.IsVerified && x.InitialCoinOfferingSourceId == (int)initialCoinOfferingSource; } return(filterExpression); }