예제 #1
0
        public async Task UpdateSeasons()
        {
            logger.Log("Started UpdateSeasons job.");

            int YearinNextSixMonths = DateTime.Now.AddMonths(6).Year;

            SeasonArchives seasonArchives = await jikan.GetSeasonArchive();

            foreach (var season in seasonArchives.Archives.First(x => x.Year.Equals(YearinNextSixMonths)).Season)
            {
                var insertedSeason = await seasonRepository.GetAsync(x => x.Name.Equals(season.ToString()) &&
                                                                     x.Year.Equals(YearinNextSixMonths));

                if (insertedSeason == null)
                {
                    seasonRepository.Add(new Data.Model.Season()
                    {
                        Name = season.ToString(),
                        Year = YearinNextSixMonths
                    });
                    await seasonRepository.CommitAsync();
                }
            }

            logger.Log("Finished UpdateSeasons job.");
        }
예제 #2
0
        private void SeedSeasons()
        {
            var season = new Season
            {
                Name      = "2018/2019",
                StartDate = DateTime.Now
            };

            _seasonRepository.Add(season);
            _unitOfWork.CompleteAsync().Wait();
        }
예제 #3
0
        public void Seed()
        {
            foreach (var item in Items())
            {
                var dbItem = _seasonRepository.GetByIdOrDefault(item.Id);
                if (dbItem == null)
                {
                    _seasonRepository.Add(item);
                }
                else
                {
                    dbItem.Label = item.Label;
                    dbItem.Start = item.Start;
                    dbItem.End   = item.End;
                }
            }

            _unitOfWork.Commit();
        }
 public async Task CreateAsync(Season season)
 {
     _seasonRepository.Add(season);
     await _unitOfWork.CompleteAsync();
 }
예제 #5
0
 public void Create(Season season)
 {
     _seasonRepository.Add(season);
     _seasonRepository.Commit();
 }