public async Task <IActionResult> Remove(string id, string returnAction, string returnQuery) { var idIsValidMovieOrTVShowId = await watchlistService.IsValidMovieOrTVShowIdAsync(id); if (!idIsValidMovieOrTVShowId) { return(Redirect(GlobalConstants.redirectError)); } var userId = await userService.GetUserIdFromUserNameAsync(User.Identity.Name); var itemType = await watchlistService.IsIdMovieOrTVShowIdAsync(id); if (itemType == GlobalConstants.Movie) { if (!await watchlistService.MovieIsInUserWatchlistAsync(userId, id)) { return(Redirect(GlobalConstants.redirectError)); } await watchlistService.RemoveMovieFromUserWatchlistAsync(userId, id); return(Redirect(returnAction + returnQuery)); } else if (itemType == GlobalConstants.TV_Show) { if (!await watchlistService.TVShowIsInUserWatchlistAsync(userId, id)) { return(Redirect(GlobalConstants.redirectError)); } await watchlistService.RemoveTVShowFromUserWatchlistAsync(userId, id); return(Redirect(returnAction + returnQuery)); } else { return(Redirect(GlobalConstants.redirectError)); } }