Exemplo n.º 1
0
 public DataFixer(
     ITflService tflService,
     ILog logger)
 {
     Log        = logger;
     TflService = tflService;
 }
        /// <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);
            }
        }
Exemplo n.º 3
0
 public ArticleExaminer(
     ITflService tflService,
     ILog logger)
 {
     Log          = logger;
     TflService   = tflService;
     BulkArticles = new List <NewsArticleCommand>();
     BulkEvents   = new List <ExaminationEvent>();
     Positions    = new[]
     {
         "FB/TE",
         "WR/KR",
         "LCB",
         "RCB",
         "OLB",
         "MLB",
         "G/T",
         "ILB",
         "QB",
         "RB",
         "WR",
         "LB",
         "FB",
         "CB",
         "TE",
         "PK",
         "DT",
         "DE",
         "SS",
         "LS",
         "FS",
         "DB",
         "OG",
         "OL",
         "LE",
         "RE",
         "KR",
         "OT",
         "NT",
         "RG",
         "LG",
         "S",
         "K",
         "G"
     };
     if (TflService == null)
     {
         LogError("No TFL service available!");
     }
     else
     {
         LogTrace("Article Examiner up and running");
     }
 }
        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);
        }
Exemplo n.º 5
0
        public TransactionManager(ITflService tflService)
        {
            TflService           = tflService;
            Log                  = new NLogAdaptor();
            ProcessingStrategies = new Dictionary <string, IProcessTransaction>
            {
                { "SIGN", new PlayerSigningStrategy(TflService) },
                { "TRADE", new PlayerTradingStrategy(TflService) },
                { "CUT", new PlayerCutStrategy(TflService) },
                { "WAIVER", new PlayerCutStrategy(TflService) },
                { "RETIRED", new PlayerRetirementStrategy(TflService) },
                { "NEWBIE", new NewbieStrategy(TflService) },
                { "INJURY", new PlayerInjuredStrategy(TflService) }
            };
            Log.Trace($@"TransactionManager instantiated with {
				ProcessingStrategies.Count
				} strategies"                );
        }
 public PlayerInjuredStrategy(ITflService tflService)
 {
     TflService = tflService;
 }
 public PlayerSigningStrategy(
     ITflService tflService)
 {
     TflService = tflService;
 }
Exemplo n.º 8
0
 public PlayerTradingStrategy(ITflService tflService)
 {
     TflService = tflService;
 }
Exemplo n.º 9
0
 public NewbieStrategy(ITflService tflService)
 {
     this.tflService = tflService;
 }
 public TransportController(ITflService Service)
 {
     _service = Service;
 }
Exemplo n.º 11
0
 public PlayerRetirementStrategy(ITflService tflService)
 {
     TflService = tflService;
 }
Exemplo n.º 12
0
 public PlayerCutStrategy(ITflService tflService)
 {
     TflService = tflService;
 }