|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Ombi.Helpers;
|
|
|
|
|
using Ombi.Store.Context;
|
|
|
|
|
using Ombi.Store.Entities.Requests;
|
|
|
|
|
|
|
|
|
@ -101,20 +102,20 @@ namespace Ombi.Store.Repository.Requests
|
|
|
|
|
|
|
|
|
|
public async Task Save()
|
|
|
|
|
{
|
|
|
|
|
await Db.SaveChangesAsync();
|
|
|
|
|
await InternalSaveChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<TvRequests> Add(TvRequests request)
|
|
|
|
|
{
|
|
|
|
|
await Db.TvRequests.AddAsync(request);
|
|
|
|
|
await Db.SaveChangesAsync();
|
|
|
|
|
await InternalSaveChanges();
|
|
|
|
|
return request;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<ChildRequests> AddChild(ChildRequests request)
|
|
|
|
|
{
|
|
|
|
|
await Db.ChildRequests.AddAsync(request);
|
|
|
|
|
await Db.SaveChangesAsync();
|
|
|
|
|
await InternalSaveChanges();
|
|
|
|
|
|
|
|
|
|
return request;
|
|
|
|
|
}
|
|
|
|
@ -122,33 +123,38 @@ namespace Ombi.Store.Repository.Requests
|
|
|
|
|
public async Task Delete(TvRequests request)
|
|
|
|
|
{
|
|
|
|
|
Db.TvRequests.Remove(request);
|
|
|
|
|
await Db.SaveChangesAsync();
|
|
|
|
|
await InternalSaveChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task DeleteChild(ChildRequests request)
|
|
|
|
|
{
|
|
|
|
|
Db.ChildRequests.Remove(request);
|
|
|
|
|
await Db.SaveChangesAsync();
|
|
|
|
|
await InternalSaveChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task DeleteChildRange(IEnumerable<ChildRequests> request)
|
|
|
|
|
{
|
|
|
|
|
Db.ChildRequests.RemoveRange(request);
|
|
|
|
|
await Db.SaveChangesAsync();
|
|
|
|
|
await InternalSaveChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task Update(TvRequests request)
|
|
|
|
|
{
|
|
|
|
|
Db.Update(request);
|
|
|
|
|
|
|
|
|
|
await Db.SaveChangesAsync();
|
|
|
|
|
await InternalSaveChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task UpdateChild(ChildRequests request)
|
|
|
|
|
{
|
|
|
|
|
Db.Update(request);
|
|
|
|
|
|
|
|
|
|
await Db.SaveChangesAsync();
|
|
|
|
|
await InternalSaveChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<int> InternalSaveChanges()
|
|
|
|
|
{
|
|
|
|
|
return await GlobalMutex.Lock(async () => await Db.SaveChangesAsync());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|