diff --git a/Ombi/Ombi.Core/Engine/TvRequestEngine.cs b/Ombi/Ombi.Core/Engine/TvRequestEngine.cs index a6cf368cf..610b52629 100644 --- a/Ombi/Ombi.Core/Engine/TvRequestEngine.cs +++ b/Ombi/Ombi.Core/Engine/TvRequestEngine.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.Linq; using System.Security.Principal; using System.Threading.Tasks; +using AutoMapper; using Hangfire; using Ombi.Api.TvMaze; using Ombi.Core.Models.Requests; @@ -17,13 +18,15 @@ namespace Ombi.Core.Engine { public class TvRequestEngine : BaseMediaEngine, ITvRequestEngine { - public TvRequestEngine(ITvMazeApi tvApi, IRequestServiceMain requestService, IPrincipal user, INotificationService notificationService) : base(user, requestService) + public TvRequestEngine(ITvMazeApi tvApi, IRequestServiceMain requestService, IPrincipal user, INotificationService notificationService, IMapper map) : base(user, requestService) { TvApi = tvApi; NotificationService = notificationService; + Mapper = map; } private INotificationService NotificationService { get; } private ITvMazeApi TvApi { get; } + private IMapper Mapper { get; } public async Task RequestTvShow(SearchTvShowViewModel tv) { @@ -166,6 +169,16 @@ namespace Ombi.Core.Engine newRequest.SeasonRequests = episodeDifference; } + if (!existingRequest.HasChildRequests) + { + // So this is the first child request, we will want to convert the original request to a child + var originalRequest = Mapper.Map(existingRequest); + existingRequest.ChildRequests.Add(originalRequest); + existingRequest.RequestedUsers.Clear(); + existingRequest.Approved = false; + existingRequest.Available = false; + } + existingRequest.ChildRequests.Add(newRequest); TvRequestService.UpdateRequest(existingRequest); diff --git a/Ombi/Ombi/package.json b/Ombi/Ombi/package.json index c6800452a..193498c2d 100644 --- a/Ombi/Ombi/package.json +++ b/Ombi/Ombi/package.json @@ -27,7 +27,7 @@ "gulp-clean-css": "^3.0.4", "gulp-filter": "^5.0.0", "gulp-if": "^2.0.2", - "gulp-rename": "^1.2.2", + "gulp-rename": "^1.2.2", "gulp-run": "^1.7.1", "gulp-sass": "^2.3.2", "gulp-sourcemaps": "^1.9.0", diff --git a/Ombi/Ombi/wwwroot/app/app.component.html b/Ombi/Ombi/wwwroot/app/app.component.html index 442f78863..82d6a8957 100644 --- a/Ombi/Ombi/wwwroot/app/app.component.html +++ b/Ombi/Ombi/wwwroot/app/app.component.html @@ -1,4 +1,4 @@ - +