31 lines
817 B
C#
31 lines
817 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Portoa.Persistence;
|
|
using Portoa.Search;
|
|
|
|
namespace VideoGameQuotes.Web.Search {
|
|
public class SearchService<T, TId> : ISearchService<T, TId> where T : IIdentifiable<TId> {
|
|
private readonly IRepository<T, TId> repository;
|
|
|
|
public SearchService(IRepository<T, TId> repository) {
|
|
this.repository = repository;
|
|
}
|
|
|
|
[UnitOfWork]
|
|
public IEnumerable<T> FindByIds(IEnumerable<TId> ids) {
|
|
return repository
|
|
.Records
|
|
.Where(entity => ids.ToArray().Contains(entity.Id));
|
|
}
|
|
|
|
[UnitOfWork]
|
|
public IEnumerable<T> GetAllIndexableRecords() {
|
|
return repository.Records;
|
|
}
|
|
|
|
public TId ConvertIdFromStringValue(string idValue) {
|
|
return (TId)Convert.ChangeType(idValue, typeof(TId));
|
|
}
|
|
}
|
|
} |