|
|
|
@ -31,14 +31,13 @@ namespace Ombi.Core.Engine
|
|
|
|
|
{
|
|
|
|
|
public TvRequestEngine(ITvMazeApi tvApi, IMovieDbApi movApi, IRequestServiceMain requestService, IPrincipal user,
|
|
|
|
|
INotificationHelper helper, IRuleEvaluator rule, OmbiUserManager manager,
|
|
|
|
|
ITvSender sender, IAuditRepository audit, IRepository<RequestLog> rl, ISettingsService<OmbiSettings> settings, ICacheService cache,
|
|
|
|
|
ITvSender sender, IRepository<RequestLog> rl, ISettingsService<OmbiSettings> settings, ICacheService cache,
|
|
|
|
|
IRepository<RequestSubscription> sub) : base(user, requestService, rule, manager, cache, settings, sub)
|
|
|
|
|
{
|
|
|
|
|
TvApi = tvApi;
|
|
|
|
|
MovieDbApi = movApi;
|
|
|
|
|
NotificationHelper = helper;
|
|
|
|
|
TvSender = sender;
|
|
|
|
|
Audit = audit;
|
|
|
|
|
_requestLog = rl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -46,7 +45,6 @@ namespace Ombi.Core.Engine
|
|
|
|
|
private ITvMazeApi TvApi { get; }
|
|
|
|
|
private IMovieDbApi MovieDbApi { get; }
|
|
|
|
|
private ITvSender TvSender { get; }
|
|
|
|
|
private IAuditRepository Audit { get; }
|
|
|
|
|
private readonly IRepository<RequestLog> _requestLog;
|
|
|
|
|
|
|
|
|
|
public async Task<RequestEngineResult> RequestTvShow(TvRequestViewModel tv)
|
|
|
|
@ -351,7 +349,6 @@ namespace Ombi.Core.Engine
|
|
|
|
|
|
|
|
|
|
public async Task<TvRequests> UpdateTvRequest(TvRequests request)
|
|
|
|
|
{
|
|
|
|
|
await Audit.Record(AuditType.Updated, AuditArea.TvRequest, $"Updated Request {request.Title}", Username);
|
|
|
|
|
var allRequests = TvRepository.Get();
|
|
|
|
|
var results = await allRequests.FirstOrDefaultAsync(x => x.Id == request.Id);
|
|
|
|
|
|
|
|
|
@ -394,7 +391,6 @@ namespace Ombi.Core.Engine
|
|
|
|
|
if (request.Approved)
|
|
|
|
|
{
|
|
|
|
|
NotificationHelper.Notify(request, NotificationType.RequestApproved);
|
|
|
|
|
await Audit.Record(AuditType.Approved, AuditArea.TvRequest, $"Approved Request {request.Title}", Username);
|
|
|
|
|
// Autosend
|
|
|
|
|
await TvSender.Send(request);
|
|
|
|
|
}
|
|
|
|
@ -426,9 +422,7 @@ namespace Ombi.Core.Engine
|
|
|
|
|
|
|
|
|
|
public async Task<ChildRequests> UpdateChildRequest(ChildRequests request)
|
|
|
|
|
{
|
|
|
|
|
await Audit.Record(AuditType.Updated, AuditArea.TvRequest, $"Updated Request {request.Title}", Username);
|
|
|
|
|
|
|
|
|
|
await TvRepository.UpdateChild(request);
|
|
|
|
|
await TvRepository.UpdateChild(request);
|
|
|
|
|
return request;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -446,16 +440,14 @@ namespace Ombi.Core.Engine
|
|
|
|
|
// Delete the parent
|
|
|
|
|
TvRepository.Db.TvRequests.Remove(parent);
|
|
|
|
|
}
|
|
|
|
|
await Audit.Record(AuditType.Deleted, AuditArea.TvRequest, $"Deleting Request {request.Title}", Username);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await TvRepository.Db.SaveChangesAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task RemoveTvRequest(int requestId)
|
|
|
|
|
{
|
|
|
|
|
var request = await TvRepository.Get().FirstOrDefaultAsync(x => x.Id == requestId);
|
|
|
|
|
await Audit.Record(AuditType.Deleted, AuditArea.TvRequest, $"Deleting Request {request.Title}", Username);
|
|
|
|
|
await TvRepository.Delete(request);
|
|
|
|
|
await TvRepository.Delete(request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<bool> UserHasRequest(string userId)
|
|
|
|
|