2011-02-25 23:36:21 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Portoa.Persistence;
|
2011-02-26 01:08:38 +00:00
|
|
|
|
using Portoa.Search;
|
2011-02-25 23:36:21 +00:00
|
|
|
|
|
2011-02-26 01:08:38 +00:00
|
|
|
|
namespace VideoGameQuotes.Web.Search {
|
2011-02-25 23:36:21 +00:00
|
|
|
|
public class SearchService<T> : ISearchService<T> where T : Entity<T, int> {
|
|
|
|
|
private readonly IRepository<T> repository;
|
|
|
|
|
|
|
|
|
|
public SearchService(IRepository<T> repository) {
|
|
|
|
|
this.repository = repository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[UnitOfWork]
|
|
|
|
|
public IEnumerable<T> FindByIds(IEnumerable<int> ids) {
|
|
|
|
|
return repository
|
|
|
|
|
.Records
|
|
|
|
|
.Where(entity => ids.ToArray().Contains(entity.Id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[UnitOfWork]
|
|
|
|
|
public IEnumerable<T> GetAllIndexableRecords() {
|
|
|
|
|
return repository.Records;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|