/// <summary>
        /// Maps the user's preferences onto the specified view model as an asynchronous operation.
        /// </summary>
        /// <param name="model">The view model to map.</param>
        /// <param name="cancellationToken">The cancellation token to use.</param>
        /// <returns>
        /// A <see cref="Task"/> representing the asynchronous operation to map the view model.
        /// </returns>
        private async Task MapPreferencesAsync(LinePreferencesViewModel model, CancellationToken cancellationToken)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                _logger?.LogError($"Failed to get user to render preferences.");
                return;
            }

            model.ETag            = user.ETag;
            model.IsAuthenticated = true;
            model.IsLinkedToAlexa = !string.IsNullOrWhiteSpace(user.AlexaToken);

            ITflService            service = _tflFactory.CreateService();
            ICollection <LineInfo> lines   = await service.GetLinesAsync(cancellationToken);

            MapFavoriteLines(model, lines, user.FavoriteLines);

            string updateResult = HttpContext.Request.Query["UpdateSuccess"].FirstOrDefault();

            if (!string.IsNullOrEmpty(updateResult))
            {
                model.UpdateResult = string.Equals(updateResult, bool.TrueString, StringComparison.OrdinalIgnoreCase);
            }
        }
        private async Task <bool> AreLinesValidAsync(UpdateLinePreferencesViewModel model, CancellationToken cancellationToken)
        {
            if (model.FavoriteLines != null)
            {
                ITflService            service = _tflServiceFactory.CreateService();
                ICollection <LineInfo> lines   = await service.GetLinesAsync(cancellationToken);

                IList <string> validLines = lines.Select((p) => p.Id).ToList();

                return(model.FavoriteLines.All((p) => validLines.Contains(p)));
            }

            return(true);
        }