mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-07 05:31:13 -07:00
Added four new endpoints to change the availability for TV shows and Movies #1601
This commit is contained in:
parent
b4d01386a6
commit
f5ffa78304
14 changed files with 207 additions and 44 deletions
|
@ -14,5 +14,8 @@ namespace Ombi.Core.Engine.Interfaces
|
||||||
Task<IEnumerable<T>> GetRequests(int count, int position);
|
Task<IEnumerable<T>> GetRequests(int count, int position);
|
||||||
Task<IEnumerable<T>> GetRequests();
|
Task<IEnumerable<T>> GetRequests();
|
||||||
Task<bool> UserHasRequest(string userId);
|
Task<bool> UserHasRequest(string userId);
|
||||||
|
|
||||||
|
Task<RequestEngineResult> MarkUnavailable(int modelId);
|
||||||
|
Task<RequestEngineResult> MarkAvailable(int modelId);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,7 +11,6 @@ namespace Ombi.Core.Engine.Interfaces
|
||||||
Task RemoveTvRequest(int requestId);
|
Task RemoveTvRequest(int requestId);
|
||||||
Task<RequestEngineResult> RequestTvShow(SearchTvShowViewModel tv);
|
Task<RequestEngineResult> RequestTvShow(SearchTvShowViewModel tv);
|
||||||
Task<RequestEngineResult> DenyChildRequest(int requestId);
|
Task<RequestEngineResult> DenyChildRequest(int requestId);
|
||||||
Task<ChildRequests> ChangeAvailability(ChildRequests request);
|
|
||||||
Task<IEnumerable<TvRequests>> SearchTvRequest(string search);
|
Task<IEnumerable<TvRequests>> SearchTvRequest(string search);
|
||||||
Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> SearchTvRequestTree(string search);
|
Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> SearchTvRequestTree(string search);
|
||||||
Task<TvRequests> UpdateTvRequest(TvRequests request);
|
Task<TvRequests> UpdateTvRequest(TvRequests request);
|
||||||
|
|
|
@ -9,7 +9,6 @@ using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Core.Authentication;
|
using Ombi.Core.Authentication;
|
||||||
|
@ -48,7 +47,7 @@ namespace Ombi.Core.Engine
|
||||||
{
|
{
|
||||||
return new RequestEngineResult
|
return new RequestEngineResult
|
||||||
{
|
{
|
||||||
RequestAdded = false,
|
Result = false,
|
||||||
Message = "There was an issue adding this movie!",
|
Message = "There was an issue adding this movie!",
|
||||||
ErrorMessage = $"TheMovieDb didn't have any information for ID {model.Id}"
|
ErrorMessage = $"TheMovieDb didn't have any information for ID {model.Id}"
|
||||||
};
|
};
|
||||||
|
@ -87,7 +86,7 @@ namespace Ombi.Core.Engine
|
||||||
if (requestModel.Approved) // The rules have auto approved this
|
if (requestModel.Approved) // The rules have auto approved this
|
||||||
{
|
{
|
||||||
var requestEngineResult = await AddMovieRequest(requestModel, fullMovieName);
|
var requestEngineResult = await AddMovieRequest(requestModel, fullMovieName);
|
||||||
if (requestEngineResult.RequestAdded)
|
if (requestEngineResult.Result)
|
||||||
{
|
{
|
||||||
var result = await ApproveMovie(requestModel);
|
var result = await ApproveMovie(requestModel);
|
||||||
if (result.IsError)
|
if (result.IsError)
|
||||||
|
@ -97,7 +96,7 @@ namespace Ombi.Core.Engine
|
||||||
{
|
{
|
||||||
Message = result.Message,
|
Message = result.Message,
|
||||||
ErrorMessage = result.Message,
|
ErrorMessage = result.Message,
|
||||||
RequestAdded = false
|
Result = false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +202,7 @@ namespace Ombi.Core.Engine
|
||||||
{
|
{
|
||||||
return new RequestEngineResult
|
return new RequestEngineResult
|
||||||
{
|
{
|
||||||
RequestAdded = true
|
Result = true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (!result.Success)
|
if (!result.Success)
|
||||||
|
@ -213,7 +212,7 @@ namespace Ombi.Core.Engine
|
||||||
{
|
{
|
||||||
Message = result.Message,
|
Message = result.Message,
|
||||||
ErrorMessage = result.Message,
|
ErrorMessage = result.Message,
|
||||||
RequestAdded = false
|
Result = false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// If there are no providers then it's successful but movie has not been sent
|
// If there are no providers then it's successful but movie has not been sent
|
||||||
|
@ -221,7 +220,7 @@ namespace Ombi.Core.Engine
|
||||||
|
|
||||||
return new RequestEngineResult
|
return new RequestEngineResult
|
||||||
{
|
{
|
||||||
RequestAdded = true
|
Result = true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,6 +266,47 @@ namespace Ombi.Core.Engine
|
||||||
return await MovieRepository.GetAll().AnyAsync(x => x.RequestedUserId == userId);
|
return await MovieRepository.GetAll().AnyAsync(x => x.RequestedUserId == userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<RequestEngineResult> MarkUnavailable(int modelId)
|
||||||
|
{
|
||||||
|
var request = await MovieRepository.Find(modelId);
|
||||||
|
if (request == null)
|
||||||
|
{
|
||||||
|
return new RequestEngineResult
|
||||||
|
{
|
||||||
|
ErrorMessage = "Request does not exist"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
request.Available = false;
|
||||||
|
await MovieRepository.Update(request);
|
||||||
|
|
||||||
|
return new RequestEngineResult
|
||||||
|
{
|
||||||
|
Message = "Request is now unavailable",
|
||||||
|
Result = true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RequestEngineResult> MarkAvailable(int modelId)
|
||||||
|
{
|
||||||
|
var request = await MovieRepository.Find(modelId);
|
||||||
|
if (request == null)
|
||||||
|
{
|
||||||
|
return new RequestEngineResult
|
||||||
|
{
|
||||||
|
ErrorMessage = "Request does not exist"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
request.Available = true;
|
||||||
|
NotificationHelper.Notify(request, NotificationType.RequestAvailable);
|
||||||
|
await MovieRepository.Update(request);
|
||||||
|
|
||||||
|
return new RequestEngineResult
|
||||||
|
{
|
||||||
|
Message = "Request is now available",
|
||||||
|
Result = true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<RequestEngineResult> AddMovieRequest(MovieRequests model, string movieName)
|
private async Task<RequestEngineResult> AddMovieRequest(MovieRequests model, string movieName)
|
||||||
{
|
{
|
||||||
await MovieRepository.Add(model);
|
await MovieRepository.Add(model);
|
||||||
|
@ -277,7 +317,7 @@ namespace Ombi.Core.Engine
|
||||||
NotificationHelper.NewRequest(model);
|
NotificationHelper.NewRequest(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RequestEngineResult { RequestAdded = true, Message = $"{movieName} has been successfully added!" };
|
return new RequestEngineResult { Result = true, Message = $"{movieName} has been successfully added!" };
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<MovieRequests>> GetApprovedRequests()
|
public async Task<IEnumerable<MovieRequests>> GetApprovedRequests()
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{
|
{
|
||||||
public class RequestEngineResult
|
public class RequestEngineResult
|
||||||
{
|
{
|
||||||
public bool RequestAdded { get; set; }
|
public bool Result { get; set; }
|
||||||
public string Message { get; set; }
|
public string Message { get; set; }
|
||||||
public bool IsError => !string.IsNullOrEmpty(ErrorMessage);
|
public bool IsError => !string.IsNullOrEmpty(ErrorMessage);
|
||||||
public string ErrorMessage { get; set; }
|
public string ErrorMessage { get; set; }
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace Ombi.Core.Engine
|
||||||
// Looks like we have removed them all! They were all duplicates...
|
// Looks like we have removed them all! They were all duplicates...
|
||||||
return new RequestEngineResult
|
return new RequestEngineResult
|
||||||
{
|
{
|
||||||
RequestAdded = false,
|
Result = false,
|
||||||
ErrorMessage = "This has already been requested"
|
ErrorMessage = "This has already been requested"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ namespace Ombi.Core.Engine
|
||||||
}
|
}
|
||||||
return new RequestEngineResult
|
return new RequestEngineResult
|
||||||
{
|
{
|
||||||
RequestAdded = true
|
Result = true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,19 +220,10 @@ namespace Ombi.Core.Engine
|
||||||
NotificationHelper.Notify(request, NotificationType.RequestDeclined);
|
NotificationHelper.Notify(request, NotificationType.RequestDeclined);
|
||||||
return new RequestEngineResult
|
return new RequestEngineResult
|
||||||
{
|
{
|
||||||
RequestAdded = true
|
Result = true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ChildRequests> ChangeAvailability(ChildRequests request)
|
|
||||||
{
|
|
||||||
if (request.Available)
|
|
||||||
{
|
|
||||||
NotificationHelper.Notify(request, NotificationType.RequestAvailable);
|
|
||||||
}
|
|
||||||
return await UpdateChildRequest(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<ChildRequests> UpdateChildRequest(ChildRequests request)
|
public async Task<ChildRequests> UpdateChildRequest(ChildRequests request)
|
||||||
{
|
{
|
||||||
await Audit.Record(AuditType.Updated, AuditArea.TvRequest, $"Updated Request {request.Title}", Username);
|
await Audit.Record(AuditType.Updated, AuditArea.TvRequest, $"Updated Request {request.Title}", Username);
|
||||||
|
@ -272,6 +263,46 @@ namespace Ombi.Core.Engine
|
||||||
return await TvRepository.GetChild().AnyAsync(x => x.RequestedUserId == userId);
|
return await TvRepository.GetChild().AnyAsync(x => x.RequestedUserId == userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<RequestEngineResult> MarkUnavailable(int modelId)
|
||||||
|
{
|
||||||
|
var request = await TvRepository.GetChild().FirstOrDefaultAsync(x => x.Id == modelId);
|
||||||
|
if (request == null)
|
||||||
|
{
|
||||||
|
return new RequestEngineResult
|
||||||
|
{
|
||||||
|
ErrorMessage = "Child Request does not exist"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
request.Available = false;
|
||||||
|
await TvRepository.UpdateChild(request);
|
||||||
|
NotificationHelper.Notify(request, NotificationType.RequestAvailable);
|
||||||
|
return new RequestEngineResult
|
||||||
|
{
|
||||||
|
Result = true,
|
||||||
|
Message = "Request is now unavailable",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RequestEngineResult> MarkAvailable(int modelId)
|
||||||
|
{
|
||||||
|
var request = await TvRepository.GetChild().FirstOrDefaultAsync(x => x.Id == modelId);
|
||||||
|
if (request == null)
|
||||||
|
{
|
||||||
|
return new RequestEngineResult
|
||||||
|
{
|
||||||
|
ErrorMessage = "Child Request does not exist"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
request.Available = true;
|
||||||
|
await TvRepository.UpdateChild(request);
|
||||||
|
NotificationHelper.Notify(request, NotificationType.RequestAvailable);
|
||||||
|
return new RequestEngineResult
|
||||||
|
{
|
||||||
|
Result = true,
|
||||||
|
Message = "Request is now available",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<RequestEngineResult> AddExistingRequest(ChildRequests newRequest, TvRequests existingRequest)
|
private async Task<RequestEngineResult> AddExistingRequest(ChildRequests newRequest, TvRequests existingRequest)
|
||||||
{
|
{
|
||||||
// Add the child
|
// Add the child
|
||||||
|
@ -339,7 +370,7 @@ namespace Ombi.Core.Engine
|
||||||
var result = await TvSender.Send(model);
|
var result = await TvSender.Send(model);
|
||||||
if (result.Success)
|
if (result.Success)
|
||||||
{
|
{
|
||||||
return new RequestEngineResult {RequestAdded = true};
|
return new RequestEngineResult {Result = true};
|
||||||
}
|
}
|
||||||
return new RequestEngineResult
|
return new RequestEngineResult
|
||||||
{
|
{
|
||||||
|
@ -347,7 +378,7 @@ namespace Ombi.Core.Engine
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RequestEngineResult {RequestAdded = true};
|
return new RequestEngineResult {Result = true};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
export interface IRequestEngineResult {
|
export interface IRequestEngineResult {
|
||||||
requestAdded: boolean;
|
result: boolean;
|
||||||
message: string;
|
message: string;
|
||||||
errorMessage: string;
|
errorMessage: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,27 @@ export class MovieRequestsComponent implements OnInit {
|
||||||
public changeAvailability(request: IMovieRequests, available: boolean) {
|
public changeAvailability(request: IMovieRequests, available: boolean) {
|
||||||
request.available = available;
|
request.available = available;
|
||||||
|
|
||||||
this.updateRequest(request);
|
if(available) {
|
||||||
|
this.requestService.markMovieAvailable({ id: request.id }).subscribe(x => {
|
||||||
|
if (x.result) {
|
||||||
|
this.notificationService.success("Request Available",
|
||||||
|
`${request.title} Is now available`);
|
||||||
|
} else {
|
||||||
|
this.notificationService.warning("Request Available", x.message ? x.message : x.errorMessage);
|
||||||
|
request.approved = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.requestService.markMovieUnavailable({ id: request.id }).subscribe(x => {
|
||||||
|
if (x.result) {
|
||||||
|
this.notificationService.success("Request Available",
|
||||||
|
`${request.title} Is now unavailable`);
|
||||||
|
} else {
|
||||||
|
this.notificationService.warning("Request Available", x.message ? x.message : x.errorMessage);
|
||||||
|
request.approved = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public approve(request: IMovieRequests) {
|
public approve(request: IMovieRequests) {
|
||||||
|
@ -119,7 +139,7 @@ export class MovieRequestsComponent implements OnInit {
|
||||||
this.requestService.approveMovie({ id: request.id })
|
this.requestService.approveMovie({ id: request.id })
|
||||||
.subscribe(x => {
|
.subscribe(x => {
|
||||||
|
|
||||||
if (x.requestAdded) {
|
if (x.result) {
|
||||||
this.notificationService.success("Request Approved",
|
this.notificationService.success("Request Approved",
|
||||||
`Request for ${request.title} has been approved successfully`);
|
`Request for ${request.title} has been approved successfully`);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -25,6 +25,27 @@ export class TvRequestChildrenComponent {
|
||||||
|
|
||||||
public changeAvailability(request: IChildRequests, available: boolean) {
|
public changeAvailability(request: IChildRequests, available: boolean) {
|
||||||
request.available = available;
|
request.available = available;
|
||||||
|
if(available) {
|
||||||
|
this.requestService.markTvAvailable({ id: request.id }).subscribe(x => {
|
||||||
|
if (x.result) {
|
||||||
|
this.notificationService.success("Request Available",
|
||||||
|
`This request is now available`);
|
||||||
|
} else {
|
||||||
|
this.notificationService.warning("Request Available", x.message ? x.message : x.errorMessage);
|
||||||
|
request.approved = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.requestService.markTvUnavailable({ id: request.id }).subscribe(x => {
|
||||||
|
if (x.result) {
|
||||||
|
this.notificationService.success("Request Available",
|
||||||
|
`This request is now unavailable`);
|
||||||
|
} else {
|
||||||
|
this.notificationService.warning("Request Available", x.message ? x.message : x.errorMessage);
|
||||||
|
request.approved = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public deny(request: IChildRequests) {
|
public deny(request: IChildRequests) {
|
||||||
|
@ -37,7 +58,7 @@ export class TvRequestChildrenComponent {
|
||||||
});
|
});
|
||||||
this.requestService.denyChild({ id: request.id })
|
this.requestService.denyChild({ id: request.id })
|
||||||
.subscribe(x => {
|
.subscribe(x => {
|
||||||
if (x.requestAdded) {
|
if (x.result) {
|
||||||
this.notificationService.success("Request Denied",
|
this.notificationService.success("Request Denied",
|
||||||
`Request has been denied successfully`);
|
`Request has been denied successfully`);
|
||||||
} else {
|
} else {
|
||||||
|
@ -57,7 +78,7 @@ export class TvRequestChildrenComponent {
|
||||||
});
|
});
|
||||||
this.requestService.approveChild({ id: request.id })
|
this.requestService.approveChild({ id: request.id })
|
||||||
.subscribe(x => {
|
.subscribe(x => {
|
||||||
if (x.requestAdded) {
|
if (x.result) {
|
||||||
this.notificationService.success("Request Approved",
|
this.notificationService.success("Request Approved",
|
||||||
`Request has been approved successfully`);
|
`Request has been approved successfully`);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -49,7 +49,7 @@ export class MovieSearchComponent implements OnInit {
|
||||||
this.movieResults = [];
|
this.movieResults = [];
|
||||||
this.result = {
|
this.result = {
|
||||||
message: "",
|
message: "",
|
||||||
requestAdded: false,
|
result: false,
|
||||||
errorMessage: "",
|
errorMessage: "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ export class MovieSearchComponent implements OnInit {
|
||||||
.subscribe(x => {
|
.subscribe(x => {
|
||||||
this.result = x;
|
this.result = x;
|
||||||
|
|
||||||
if (this.result.requestAdded) {
|
if (this.result.result) {
|
||||||
this.notificationService.success("Request Added",
|
this.notificationService.success("Request Added",
|
||||||
`Request for ${searchResult.title} has been added successfully`);
|
`Request for ${searchResult.title} has been added successfully`);
|
||||||
searchResult.processed = true;
|
searchResult.processed = true;
|
||||||
|
|
|
@ -50,7 +50,7 @@ export class MovieSearchGridComponent implements OnInit {
|
||||||
this.movieResults = [];
|
this.movieResults = [];
|
||||||
this.result = {
|
this.result = {
|
||||||
message: "",
|
message: "",
|
||||||
requestAdded: false,
|
result: false,
|
||||||
errorMessage: "",
|
errorMessage: "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ export class MovieSearchGridComponent implements OnInit {
|
||||||
.subscribe(x => {
|
.subscribe(x => {
|
||||||
this.result = x;
|
this.result = x;
|
||||||
|
|
||||||
if (this.result.requestAdded) {
|
if (this.result.result) {
|
||||||
this.notificationService.success("Request Added",
|
this.notificationService.success("Request Added",
|
||||||
`Request for ${searchResult.title} has been added successfully`);
|
`Request for ${searchResult.title} has been added successfully`);
|
||||||
searchResult.processed = true;
|
searchResult.processed = true;
|
||||||
|
|
|
@ -43,7 +43,7 @@ export class SeriesInformationComponent implements OnInit, OnDestroy {
|
||||||
.takeUntil(this.subscriptions)
|
.takeUntil(this.subscriptions)
|
||||||
.subscribe(x => {
|
.subscribe(x => {
|
||||||
this.result = x as IRequestEngineResult;
|
this.result = x as IRequestEngineResult;
|
||||||
if (this.result.requestAdded) {
|
if (this.result.result) {
|
||||||
this.notificationService.success("Request Added",
|
this.notificationService.success("Request Added",
|
||||||
`Request for ${this.series.title} has been added successfully`);
|
`Request for ${this.series.title} has been added successfully`);
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ export class TvSearchComponent implements OnInit, OnDestroy {
|
||||||
this.tvResults = [];
|
this.tvResults = [];
|
||||||
this.result = {
|
this.result = {
|
||||||
message: "",
|
message: "",
|
||||||
requestAdded: false,
|
result: false,
|
||||||
errorMessage:"",
|
errorMessage:"",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ export class TvSearchComponent implements OnInit, OnDestroy {
|
||||||
.takeUntil(this.subscriptions)
|
.takeUntil(this.subscriptions)
|
||||||
.subscribe(x => {
|
.subscribe(x => {
|
||||||
this.result = x;
|
this.result = x;
|
||||||
if (this.result.requestAdded) {
|
if (this.result.result) {
|
||||||
this.notificationService.success("Request Added",
|
this.notificationService.success("Request Added",
|
||||||
`Request for ${searchResult.title} has been added successfully`);
|
`Request for ${searchResult.title} has been added successfully`);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -33,6 +33,14 @@ export class RequestService extends ServiceAuthHelpers {
|
||||||
return this.http.put(`${this.url}Movie/Deny`, JSON.stringify(movie), { headers: this.headers }).map(this.extractData);
|
return this.http.put(`${this.url}Movie/Deny`, JSON.stringify(movie), { headers: this.headers }).map(this.extractData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public markMovieAvailable(movie: IMovieUpdateModel): Observable<IRequestEngineResult> {
|
||||||
|
return this.http.post(`${this.url}Movie/available`, JSON.stringify(movie), { headers: this.headers }).map(this.extractData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public markMovieUnavailable(movie: IMovieUpdateModel): Observable<IRequestEngineResult> {
|
||||||
|
return this.http.post(`${this.url}Movie/unavailable`, JSON.stringify(movie), { headers: this.headers }).map(this.extractData);
|
||||||
|
}
|
||||||
|
|
||||||
public getMovieRequests(count: number, position: number): Observable<IMovieRequests[]> {
|
public getMovieRequests(count: number, position: number): Observable<IMovieRequests[]> {
|
||||||
return this.http.get(`${this.url}movie/${count}/${position}`).map(this.extractData);
|
return this.http.get(`${this.url}movie/${count}/${position}`).map(this.extractData);
|
||||||
}
|
}
|
||||||
|
@ -75,19 +83,27 @@ export class RequestService extends ServiceAuthHelpers {
|
||||||
public removeTvRequest(request: ITvRequests) {
|
public removeTvRequest(request: ITvRequests) {
|
||||||
this.http.delete(`${this.url}tv/${request.id}`).map(this.extractData).subscribe();
|
this.http.delete(`${this.url}tv/${request.id}`).map(this.extractData).subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public markTvAvailable(movie: ITvUpdateModel): Observable<IRequestEngineResult> {
|
||||||
|
return this.http.post(`${this.url}tv/available`, JSON.stringify(movie), { headers: this.headers }).map(this.extractData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public markTvUnavailable(movie: ITvUpdateModel): Observable<IRequestEngineResult> {
|
||||||
|
return this.http.post(`${this.url}tv/unavailable`, JSON.stringify(movie), { headers: this.headers }).map(this.extractData);
|
||||||
|
}
|
||||||
|
|
||||||
public updateTvRequest(request: ITvRequests): Observable<ITvRequests> {
|
public updateTvRequest(request: ITvRequests): Observable<ITvRequests> {
|
||||||
return this.http.put(`${this.url}tv/`, JSON.stringify(request), { headers: this.headers }).map(this.extractData);
|
return this.http.put(`${this.url}tv/`, JSON.stringify(request), { headers: this.headers }).map(this.extractData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateChild(child: IChildRequests): Observable<IChildRequests> {
|
public updateChild(child: IChildRequests): Observable<IChildRequests> {
|
||||||
return this.http.put(`${this.url}tv/child`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
return this.http.put(`${this.url}tv/child`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public denyChild(child: ITvUpdateModel): Observable<IRequestEngineResult> {
|
public denyChild(child: ITvUpdateModel): Observable<IRequestEngineResult> {
|
||||||
return this.http.put(`${this.url}tv/deny`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
return this.http.put(`${this.url}tv/deny`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
||||||
}
|
}
|
||||||
public changeAvailabilityChild(child: IChildRequests): Observable<IChildRequests> {
|
|
||||||
return this.http.put(`${this.url}tv/changeavailability`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
|
||||||
}
|
|
||||||
public approveChild(child: ITvUpdateModel): Observable<IRequestEngineResult> {
|
public approveChild(child: ITvUpdateModel): Observable<IRequestEngineResult> {
|
||||||
return this.http.post(`${this.url}tv/approve`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
return this.http.post(`${this.url}tv/approve`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,28 @@ namespace Ombi.Controllers
|
||||||
return await MovieRequestEngine.ApproveMovieById(model.Id);
|
return await MovieRequestEngine.ApproveMovieById(model.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set's the specified Movie as available
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">The Movie's ID</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("movie/available")]
|
||||||
|
public async Task<RequestEngineResult> MarkMovieAvailable([FromBody] MovieUpdateModel model)
|
||||||
|
{
|
||||||
|
return await MovieRequestEngine.MarkAvailable(model.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set's the specified Movie as unavailable
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">The Movie's ID</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("movie/unavailable")]
|
||||||
|
public async Task<RequestEngineResult> MarkMovieUnAvailable([FromBody] MovieUpdateModel model)
|
||||||
|
{
|
||||||
|
return await MovieRequestEngine.MarkUnavailable(model.Id);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Denies the specified movie request.
|
/// Denies the specified movie request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -224,14 +246,25 @@ namespace Ombi.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Changes the availability of the a specific child request
|
/// Set's the specified tv child as available
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="child">The model.</param>
|
/// <param name="model">The Movie's ID</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPut("tv/changeavailability")]
|
[HttpPost("tv/available")]
|
||||||
public async Task<ChildRequests> ChangeAvailability([FromBody] ChildRequests child)
|
public async Task<RequestEngineResult> MarkTvAvailable([FromBody] TvUpdateModel model)
|
||||||
{
|
{
|
||||||
return await TvRequestEngine.ChangeAvailability(child);
|
return await TvRequestEngine.MarkAvailable(model.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set's the specified tv child as unavailable
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">The Movie's ID</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("tv/unavailable")]
|
||||||
|
public async Task<RequestEngineResult> MarkTvUnAvailable([FromBody] TvUpdateModel model)
|
||||||
|
{
|
||||||
|
return await TvRequestEngine.MarkUnavailable(model.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue