Smal changes to the api

pull/1897/head^2
tidusjar 7 years ago
parent 9f1475abb6
commit 98e99251f3

@ -1,15 +1,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Search;
using Ombi.Store.Entities;
using Ombi.Store.Entities.Requests;
namespace Ombi.Core.Engine.Interfaces
{
public interface IMovieRequestEngine : IRequestEngine<MovieRequests>
{
Task<RequestEngineResult> RequestMovie(SearchMovieViewModel model);
Task<RequestEngineResult> RequestMovie(MovieRequestViewModel model);
Task<IEnumerable<MovieRequests>> SearchMovieRequest(string search);

@ -43,16 +43,16 @@ namespace Ombi.Core.Engine
/// </summary>
/// <param name="model">The model.</param>
/// <returns></returns>
public async Task<RequestEngineResult> RequestMovie(SearchMovieViewModel model)
public async Task<RequestEngineResult> RequestMovie(MovieRequestViewModel model)
{
var movieInfo = await MovieApi.GetMovieInformation(model.Id);
var movieInfo = await MovieApi.GetMovieInformation(model.TheMovieDbId);
if (movieInfo == null || movieInfo.Id == 0)
{
return new RequestEngineResult
{
Result = false,
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.TheMovieDbId}"
};
}
var fullMovieName =

@ -0,0 +1,33 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2018 Jamie Rees
// File: MovieRequestViewModel.cs
// Created By: Jamie Rees
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
namespace Ombi.Core.Models.Requests
{
public class MovieRequestViewModel
{
public int TheMovieDbId { get; set; }
}
}

@ -111,3 +111,7 @@ export interface IEpisodesRequests {
approved: boolean;
selected: boolean; // This is for the UI only
}
export interface IMovieRequestModel {
theMovieDbId: number;
}

@ -76,7 +76,7 @@ export class MovieSearchComponent implements OnInit {
}
try {
this.requestService.requestMovie(searchResult)
this.requestService.requestMovie({ theMovieDbId: searchResult.id })
.subscribe(x => {
this.result = x;

@ -67,7 +67,7 @@ export class MovieSearchGridComponent implements OnInit {
}
try {
this.requestService.requestMovie(searchResult)
this.requestService.requestMovie({ theMovieDbId : searchResult.id})
.subscribe(x => {
this.result = x;

@ -6,8 +6,7 @@ import { Observable } from "rxjs/Rx";
import { TreeNode } from "primeng/primeng";
import { IRequestEngineResult } from "../interfaces";
import { IChildRequests, IMovieRequests, IMovieUpdateModel, ITvRequests, ITvUpdateModel } from "../interfaces";
import { ISearchMovieResult } from "../interfaces";
import { IChildRequests, IMovieRequestModel, IMovieRequests, IMovieUpdateModel, ITvRequests, ITvUpdateModel } from "../interfaces";
import { ISearchTvResult } from "../interfaces";
import { ServiceHelpers } from "./service.helpers";
@ -17,7 +16,7 @@ export class RequestService extends ServiceHelpers {
super(http, "/api/v1/Request/", platformLocation);
}
public requestMovie(movie: ISearchMovieResult): Observable<IRequestEngineResult> {
public requestMovie(movie: IMovieRequestModel): Observable<IRequestEngineResult> {
return this.http.post<IRequestEngineResult>(`${this.url}Movie/`, JSON.stringify(movie), {headers: this.headers});
}

@ -52,7 +52,7 @@ namespace Ombi.Controllers
/// <param name="movie">The movie.</param>
/// <returns></returns>
[HttpPost("movie")]
public async Task<RequestEngineResult> RequestMovie([FromBody] SearchMovieViewModel movie)
public async Task<RequestEngineResult> RequestMovie([FromBody] MovieRequestViewModel movie)
{
return await MovieRequestEngine.RequestMovie(movie);
}

Loading…
Cancel
Save