mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
#865 rework the backend data. Actually use real models rather than a JSON store.
This commit is contained in:
parent
08e389f590
commit
2bc916998c
55 changed files with 1277 additions and 702 deletions
50
src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs
Normal file
50
src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
|
||||
namespace Ombi.Store.Repository.Requests
|
||||
{
|
||||
public class MovieRequestRepository : IMovieRequestRepository
|
||||
{
|
||||
public MovieRequestRepository(IOmbiContext ctx)
|
||||
{
|
||||
Db = ctx;
|
||||
}
|
||||
|
||||
private IOmbiContext Db { get; }
|
||||
|
||||
public async Task<MovieRequests> GetRequest(int theMovieDbId)
|
||||
{
|
||||
return await Db.MovieRequests.Where(x => x.TheMovieDbId == theMovieDbId)
|
||||
.Include(x => x.RequestedUser)
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public IQueryable<MovieRequests> Get()
|
||||
{
|
||||
return Db.MovieRequests
|
||||
.Include(x => x.RequestedUser)
|
||||
.AsQueryable();
|
||||
}
|
||||
|
||||
public async Task<MovieRequests> Add(MovieRequests request)
|
||||
{
|
||||
await Db.MovieRequests.AddAsync(request);
|
||||
await Db.SaveChangesAsync();
|
||||
return request;
|
||||
}
|
||||
|
||||
public async Task Delete(MovieRequests request)
|
||||
{
|
||||
Db.MovieRequests.Remove(request);
|
||||
await Db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task Update(MovieRequests request)
|
||||
{
|
||||
await Db.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue