public async Task <IActionResult> Add(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.AddMovieToUserWatchlistAsync(userId, id); return(Redirect(returnAction + returnQuery)); } else if (itemType == GlobalConstants.TV_Show) { if (await watchlistService.TVShowIsInUserWatchlistAsync(userId, id)) { return(Redirect(GlobalConstants.redirectError)); } await watchlistService.AddTVShowToUserWatchlistAsync(userId, id); return(Redirect(returnAction + returnQuery)); } else { return(Redirect(GlobalConstants.redirectError)); } }