Exemple #1
0
 public ActionResult EditFilter(int?id)
 {
     if (id != null)
     {
         var filter = _filterService.GetFilter(id.Value);
         if (filter != null)
         {
             var model = Mapper.Map <Model.Models.Filter, EditFilterViewModel>(filter);
             foreach (var game in _gameService.GetGames())
             {
                 model.Games.Add(new SelectListItem {
                     Value = game.Value, Text = game.Name
                 });
             }
             return(View(model));
         }
     }
     return(HttpNotFound());
 }
Exemple #2
0
        public override async Task <ITgOutboundMessage> AscUserAsync(IChatDataInfo chatInfo, CancellationToken cancellationToken)
        {
            IPerformanceFilter filter = _filterService.GetFilter(chatInfo);

            IPerformanceData[] data = await _playBillResolver.RequestProcess(filter, cancellationToken);

            return(new TgOutboundMessage(await PerformancesMessage(data, filter, chatInfo.When))
            {
                IsEscaped = true
            });
        }
        public IPerformanceFilter[] GetUpdateFilters()
        {
            using var dbContext = _dbService.GetDbContext();
            if (!dbContext.Subscriptions.Any())
            {
                return(null);
            }

            List <IPerformanceFilter> mergedFilters = new List <IPerformanceFilter>();

            foreach (var subscription in dbContext.Subscriptions.Include(s => s.PerformanceFilter).AsNoTracking())
            {
                PerformanceFilterEntity newFilter = subscription.PerformanceFilter;

                if (newFilter == null)
                {
                    continue;
                }

                int      year;
                int      month;
                DateTime startDate;
                DateTime endDate;
                if (newFilter.PerformanceId == -1)
                {
                    year      = newFilter.StartDate.Year;
                    month     = newFilter.StartDate.Month;
                    startDate = new DateTime(year, month, 1);
                    endDate   = startDate.AddMonths(1).AddDays(-1);
                }
                else
                {
                    var playbillEntry = dbContext.Playbill.AsNoTracking()
                                        .FirstOrDefault(entity => entity.Id == newFilter.PerformanceId);

                    if (null == playbillEntry)
                    {
                        continue;
                    }

                    year      = playbillEntry.When.Year;
                    month     = playbillEntry.When.Month;
                    startDate = new DateTime(year, month, 1);
                    endDate   = startDate.AddMonths(1).AddDays(-1);
                }

                MergeFilters(mergedFilters, _filterService.GetFilter(startDate, endDate));
            }

            return(mergedFilters.ToArray());
        }
Exemple #4
0
        public async Task <bool> UpdateAsync(int theaterId, DateTime startDate, DateTime endDate, CancellationToken cancellationToken)
        {
            Trace.TraceInformation(" PlaybillUpdater started.");

            using var dbRepository = _dbService.GetPlaybillRepository();

            IPerformanceData[] performances = await _dataResolver.RequestProcess(_filterService.GetFilter(startDate, endDate), cancellationToken);

            foreach (var freshPerformanceData in performances)
            {
                await ProcessData(freshPerformanceData, dbRepository);
            }

            Trace.TraceInformation("PlaybillUpdater finished.");
            return(true);
        }