Database migrations (#13)
* remove last use of dbcontextfactory * add initial migration
This commit is contained in:
@@ -29,6 +29,13 @@ namespace ErsatzTV.Infrastructure.Data.Repositories
|
||||
public Task<Option<SimpleMediaCollection>> GetSimpleMediaCollection(int id) =>
|
||||
Get(id).Map(c => c.OfType<SimpleMediaCollection>().HeadOrNone());
|
||||
|
||||
public Task<Option<SimpleMediaCollection>> GetSimpleMediaCollectionWithItems(int id) =>
|
||||
_dbContext.SimpleMediaCollections
|
||||
.Include(s => s.Items)
|
||||
.ThenInclude(i => i.Source)
|
||||
.SingleOrDefaultAsync(c => c.Id == id)
|
||||
.Map(Optional);
|
||||
|
||||
public Task<Option<TelevisionMediaCollection>> GetTelevisionMediaCollection(int id) =>
|
||||
Get(id).Map(c => c.OfType<TelevisionMediaCollection>().HeadOrNone());
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ErsatzTV.Core.Domain;
|
||||
using ErsatzTV.Core.Interfaces.Repositories;
|
||||
@@ -26,6 +27,19 @@ namespace ErsatzTV.Infrastructure.Data.Repositories
|
||||
|
||||
public Task<List<MediaItem>> GetAll() => _dbContext.MediaItems.ToListAsync();
|
||||
|
||||
public Task<List<MediaItem>> Search(string searchString)
|
||||
{
|
||||
IQueryable<MediaItem> data = from c in _dbContext.MediaItems.Include(c => c.Source) select c;
|
||||
|
||||
if (!string.IsNullOrEmpty(searchString))
|
||||
{
|
||||
data = data.Where(c => EF.Functions.Like(c.Metadata.Title, $"%{searchString}%"));
|
||||
}
|
||||
|
||||
return data.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
public Task<List<MediaItem>> GetAll(MediaType mediaType) =>
|
||||
_dbContext.MediaItems
|
||||
.Include(i => i.Source)
|
||||
|
||||
Reference in New Issue
Block a user