private void MergeSeasons(InternalSeries from) { foreach (var season in from.Seasons) { var matchingSeason = Seasons.FirstOrDefault(t => t.SeasonNumber == season.SeasonNumber); if (matchingSeason == null) { Seasons.Add(season); } else { matchingSeason.AirDate = string.IsNullOrEmpty(matchingSeason.AirDate) ? season.AirDate : matchingSeason.AirDate; matchingSeason.Name = matchingSeason.Name ?? season.Name; matchingSeason.Summary = matchingSeason.Summary ?? season.Summary; matchingSeason.EpisodesCount = matchingSeason.EpisodesCount == 0 ? season.EpisodesCount : matchingSeason.EpisodesCount; if (season.Episodes != null && season.Episodes.Count > 0 && matchingSeason.Episodes != null) { MergeEpisodes(matchingSeason, season); } } } }
/// <summary> /// Добавить Сезон в список /// </summary> public void AddSeason() { var count = Seasons.Count + 1; var newSeason = new CartoonSeason { CartoonId = GlobalIdList.CartoonId, Number = count, Checked = true, CartoonEpisodes = new List <CartoonEpisode>() }; Seasons.Add(newSeason); NotifyOfPropertyChange(() => Seasons); ((CartoonsEditorViewModel)Parent).Seasons.Add(newSeason); NotifyOfPropertyChange(() => ((CartoonsEditorViewModel)Parent).Seasons); using (var ctx = new CVDbContext(AppDataPath)) { ctx.CartoonSeasons.Add(Seasons.Last()); ctx.SaveChanges(); Seasons.Last().CartoonSeasonId = ctx.CartoonSeasons.ToList().Last().CartoonSeasonId; } SelectedSeason = Seasons.Count > 0 ? Seasons.Last() : null; }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Seasons.Clear(); var seasons = await GetSeasons(); foreach (var season in seasons) { Seasons.Add(season); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
//Loading the view along with the data to be displayed public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { int id = 0; if (parameter != null) { id = (int)parameter; } var service = new MovieService(); Series = await service.GetSeriesAsync(id); var credits = await service.GetSeriesCastAndCrewAsync(id); foreach (Cast c in credits.cast) { Casts.Add(c); } foreach (Crew c in credits.crew) { Crews.Add(c); } for (int i = 0; i < Series.number_of_seasons; i++) { var season = await service.GetSeasonEpisodesAsync(id, i); Seasons.Add(season); } await base.OnNavigatedToAsync(parameter, mode, state); }
public void MergeEpisodes(IEnumerable <ITvShowEpisodeInfo> episodes, bool subtitlesNeeded) { episodes = episodes.OrderBy(e => e.Season, new SeasonComparer()).ThenBy(e => e.Episode); ITvShowEpisodeInfo lastEpisode = null; foreach (var episodeInfo in episodes) { var season = Seasons.FirstOrDefault(s => s.Season == episodeInfo.Season); if (season == null) { season = new TvShowSeason { TvShowId = Id, TvShow = this, Season = episodeInfo.Season }; Seasons.Add(season); } var episode = season.Episodes.FirstOrDefault(e => e.Episode == episodeInfo.Episode); if (episode == null) { episode = new TvShowEpisode { TvShowSeason = season }; season.Episodes.Add(episode); episode.Episode = episodeInfo.Episode; episode.BackgroundDownload = AutoDownload; episode.BackgroundSubtitleDownload = AutoDownload && subtitlesNeeded; } episode.AirDate = episodeInfo.AirDate; episode.Name = episodeInfo.Name; episode.Overview = episodeInfo.Overview; lastEpisode = episodeInfo; } if (lastEpisode != null) { for (var i = Seasons.Count - 1; i >= 0; i--) { var season = Seasons.ElementAt(i); if (season.Season > lastEpisode.Season) { Seasons.Remove(season); } else if (season.Season == lastEpisode.Season) { for (var j = season.Episodes.Count - 1; j >= 0; j--) { var episode = season.Episodes.ElementAt(j); if (episode.Episode > lastEpisode.Episode) { season.Episodes.Remove(episode); } } } } } }
void AddSeason() { SeasonViewModel season = new SeasonViewModel(); season.Changed += (o, ea) => IsChanged = true; season.Number = Seasons.Any() ? Seasons.Max(p => p.Number) + 1 : 1; Seasons.Add(season); SelectedSeason = season; }
static void AddSeasonImagesToCache(TmdbSeasonImages images, int?id, int season) { if (images != null) { // the id on the request (show) is different on the response (season) images.RequestAge = DateTime.Now.ToString(); images.Season = season; images.Id = id; Seasons.Add(images); } }
public void AddSeason(Season newSeason) { int maxSeasonId = 0; if (Seasons.Count > 0) { maxSeasonId = Seasons.Max(s => s.Id) + 1; } newSeason.Id = maxSeasonId; Seasons?.Add(newSeason); }
public static PvPSeason EnsureSeason(int num, bool replace = false) { if (!Seasons.ContainsKey(num)) { Seasons.Add(num, new PvPSeason(num)); } else if (replace || Seasons[num] == null) { Seasons[num] = new PvPSeason(num); } return(Seasons[num]); }
private void RefreshByShowId(long showId, int selectedSeason = 1) { IsLoading = true; _tvshowtimeApiService.GetShow(showId, string.Empty, true) .Subscribe(async(showResponse) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { LastLoadingDate = DateTime.Now; Seasons.Clear(); Show = showResponse.Show; RaisePropertyChanged(nameof(Show)); foreach (var episode in Show.Episodes) { var seasonGroup = Seasons.FirstOrDefault(s => s.SeasonNumber == episode.Season); if (seasonGroup == null) { seasonGroup = new ShowSeasonGroup { SeasonNumber = episode.Season }; Seasons.Add(seasonGroup); } seasonGroup.Episodes.Add(episode); } RaisePropertyChanged(nameof(MinSeasonNumber)); RaisePropertyChanged(nameof(MaxSeasonNumber)); SelectedSeason = Seasons.FirstOrDefault(s => s.SeasonNumber == selectedSeason); IsLoading = false; }); }, async(error) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { IsLoading = false; }); _toastNotificationService.ShowErrorNotification("An error happened. Please retry later."); }); }
public Trakt_ShowVM(JMMServerBinary.Contract_Trakt_Show contract) { this.Trakt_ShowID = contract.Trakt_ShowID; this.TraktID = contract.TraktID; this.Year = contract.Year; this.Overview = contract.Overview; this.TvDB_ID = contract.TvDB_ID; this.URL = contract.URL; this.Seasons = new List <Trakt_SeasonVM>(); foreach (JMMServerBinary.Contract_Trakt_Season season in contract.Seasons) { Seasons.Add(new Trakt_SeasonVM(season)); } this.Title = contract.Title; }
private void FillBasicCollections() { var serviceClient = new CRUD_ManagerServiceClient(); serviceClient.GetVendorsCompleted += (a, b) => { try { foreach (var item in b.Result) { Vendors.Add(item); } } catch (Exception ex) { var err = new ErrorWindow(ex); err.Show(); } }; serviceClient.GetAllBrandsCompleted += (s, e) => { try { foreach (var item in e.Result) { Brands.Add(item); } } catch (Exception ex) { var err = new ErrorWindow(ex); err.Show(); } }; serviceClient.GetAllBrandsAsync(LoggedUserInfo.Iserial); serviceClient.GetAllSeasonsCompleted += (s, e) => { foreach (var item in e.Result) { Seasons.Add(item); } }; serviceClient.GetAllSeasonsAsync(); }
private void mapSeasons(DataTable seasons) { Seasons.Reset(); foreach (DataRow row in seasons.Rows) { try { var season = ClassMapper.Map <Season>(row); season.ParseData(); Seasons.Add(season); } catch (Exception ex) { Console.WriteLine(ex); } } }
public async Task GetPickerValues() { var countriesList = await CountryDataStore.GetItemsAsync(); foreach (Country c in countriesList) { Countries.Add(c); } SelectedCountry = Countries.First(x => x.Id == Model.Country.Id); var citiesList = await CityDataStore.GetItemsAsync(); foreach (var item in citiesList) { Cities.Add(item); } SelectedCity = Cities.First(x => x.Id == Model.City.Id); var seasonsList = await SeasonDataStore.GetItemsAsync(); foreach (var item in seasonsList) { Seasons.Add(item); } SelectedSeason = Seasons.First(x => x.Id == Model.Season.Id); var currenciesList = await CurrencyDataStore.GetItemsAsync(); foreach (var item in currenciesList) { Currencies.Add(item); } SelectedCurrency = Currencies.First(x => x.Id == Model.Currency.Id); IsBusy = false; }
public SerialViewModel(Serial serial) : base() { PrepareViewModel(); ID = serial.ID; RTitle = serial.RTitle; OTitle = serial.OTitle; Note = serial.Note; HasLastSeason = serial.HasLastSeason; CreateDate = serial.CreateDate; Description = serial.Description; KinopoiskId = serial.KinopoiskId; Rating = new RatingWithKinopoiskViewModel(0, serial.KinopoiskRating, serial.IMDBRating); foreach (var i in serial.Seasons) { var st = new SeasonViewModel(i); st.Changed += (o, ea) => IsChanged = true; Seasons.Add(st); } Rating.Changed += (o, ea) => IsChanged = true; IsChanged = false; }
protected override void CopyFrom(IEntity entity) { var external = Helper.ConvertTo <TvShow>(entity); CopyFrom(external); AutoDownload = external.AutoDownload; IsActive = external.IsActive; Status = external.Status; LastUpdateDate = external.LastUpdateDate; var c = Seasons.Count; var ec = external.Seasons.Count; while (c > ec) { Seasons.Remove(Seasons.ElementAt(--c)); } for (var i = 0; i < ec; i++) { TvShowSeason season; if (c < i + 1) { season = new TvShowSeason { TvShowId = Id, TvShow = this }; Seasons.Add(season); } else { season = Seasons.ElementAt(i); } season.CopyFrom(external.Seasons.ElementAt(i)); } }
public void RefreshFolder() { if (TB_FolderPath.Text == "") { return; } Cursor.Current = Cursors.WaitCursor; ClearFiles(); try { BlackList = NameExtractor.PreBlackList; if (File.Exists("RenamerBlackList.txt")) { var pb = new List <string>(); foreach (var item in File.ReadAllLines("RenamerBlackList.txt")) { if (!BlackList.Contains(item)) { pb.Add(Regex.Escape(item)); } } BlackList = FormatBlackList(BlackList.Union(pb).ToArray()); } else { File.WriteAllText("RenamerBlackList.txt", ""); } } catch (Exception) { BlackList = FormatBlackList(NameExtractor.PreBlackList); } try { var Files = new List <string>(); var VideoFiles = new List <string>(); foreach (var item in Directory.EnumerateFiles(TB_FolderPath.Text, "*.*", SearchOption.AllDirectories)) { if (IsVideoFile(item) && (MovieMode || Episode.PathIsValid(item))) { VideoFiles.Add(item); if (VideoFiles.Count > 650) { throw new StackOverflowException("File Count exceeded Limit"); } } else { Files.Add(item); } } if (MovieMode) // Movie Mode { foreach (var Video in VideoFiles) { Movies.Add(new Movie(Video)); } L_SeasonCount.Text = Movies.Count.ToString(); foreach (var Movie in Movies.OrderByDescending(x => x.Name)) { Movie.Control = new MovieControl(Movie) { Dock = DockStyle.Top }; Form1.reviewSubForm.P_Main.Controls.Add(Movie.Control); Movie.Control.Show(); } } else // Series Mode { var Episodes = new List <Episode>(); foreach (var item in VideoFiles) { Episodes.Add(new Episode(item)); } foreach (var SNumber in Season.GetSeasons(Episodes)) { Seasons.Add(new Season(SNumber, Episodes.Where(x => x.SeasonNumber == SNumber).ToList())); } L_SeasonCount.Text = Seasons.Count.ToString(); L_EpCount.Text = Episodes.Count.ToString(); foreach (var Season in Seasons.OrderByDescending(x => x.SeasonNumber)) { Season.Control = new SeasonControl(Season) { Dock = DockStyle.Top }; Form1.reviewSubForm.P_Main.Controls.Add(Season.Control); Season.Control.Show(); } } if (O_IncludeSubs) { AddSubtitles(); } JunkFiles = Files.Where(f => Movies.All(m => m.FilePath != f && m.Subs.All(s => s.FilePath != f)) && Seasons.All(S => S.Episodes.All(e => e.FilePath != f && e.Subs.All(sub => sub.FilePath != f))) && !(new FileInfo(f).Attributes.HasFlag(FileAttributes.Hidden))).ToList(); if (!O_IncludeSubs) { JunkFiles.RemoveAll(x => x.EndsWith(".srt")); } L_SeasonCount.ForeColor = L_EpCount.ForeColor = L_SubCount.ForeColor = FormState.N_Focused.Color; CurrentFormState = GetFormState(); } catch (Exception ex) { ClearFiles(); Form1.ShowError(ex.Message); L_SeasonCount.Text = L_EpCount.Text = L_SubCount.Text = "0"; L_SeasonCount.ForeColor = L_EpCount.ForeColor = L_SubCount.ForeColor = Color.FromArgb(242, 60, 53); Clipboard.SetText(ex.ToString()); CurrentFormState = FormState.Busy; } Cursor.Current = Cursors.Default; }
public void ApplyFilter(bool reset, bool notifications = true) { if (AllDownloads == null || !AllDownloads.Any()) { Fetch(); return; } _mutexFilter.WaitOne(); FavSeasonData currentFavSeason = null; SeasonData currentSeasonData = null; int seasonNr = -1; ObservableCollection <FavSeasonData> newSeasons = new ObservableCollection <FavSeasonData>(); ObservableCollection <DownloadData> newNonSeasons = new ObservableCollection <DownloadData>(); bool setNewEpisodes = false; bool setNewUpdates = false; if (_isNewShow) { notifications = false; } reset = reset || _isNewShow; if (!reset) { newSeasons = Seasons; newNonSeasons = NonSeasons; } UploadData currentUpload = null; bool ignoreCurrentUpload = false; foreach (var download in AllDownloads) { //upload stuff -------------------------------------------------------------------- if (currentUpload == null || currentUpload != download.Upload) { currentUpload = download.Upload; ignoreCurrentUpload = true; do { UploadLanguage language = currentUpload.Language; if (!Settings.Instance.MarkSubbedAsGerman && currentUpload.Subbed) //dont mark german-subbed as german { language &= ~UploadLanguage.German; //remove german } if ((language & FilterLanguage) == 0) //Filter: Language { break; } if (!String.IsNullOrWhiteSpace(FilterRuntime) && //Filter: Runtime !(new Regex(FilterRuntime).Match(currentUpload.Runtime).Success)) { break; } if (!String.IsNullOrWhiteSpace(FilterSize) && //Filter: Size !(new Regex(FilterSize).Match(currentUpload.Size).Success)) { break; } if (!String.IsNullOrWhiteSpace(FilterUploader) && //Filter: Uploader !(new Regex(FilterUploader).Match(currentUpload.Uploader).Success)) { break; } if (!String.IsNullOrWhiteSpace(FilterFormat) && //Filter: Format !(new Regex(FilterFormat).Match(currentUpload.Format).Success)) { break; } ignoreCurrentUpload = false; } while (false); } if (ignoreCurrentUpload) //Filter: All upload stuff { continue; } //episode stuff --------------------- if (!String.IsNullOrWhiteSpace(FilterName) && //Filter: Name !(new Regex(FilterName).Match(download.Title).Success)) { continue; } if (!String.IsNullOrWhiteSpace(FilterHoster)) { var r = new Regex(FilterHoster); var dls = download.Links.Keys.Where(hoster => r.Match(hoster).Success).ToList(); //all keys that match the regex if (!dls.Any()) //Filter: Hoster { continue; } for (int i = download.Links.Keys.Count - 1; i >= 0; i--) { string key = download.Links.Keys.ElementAt(i); if (!dls.Contains(key)) { download.Links.Remove(key); } } } //------------------------------------------ //Season stuff ------------------------------------------------------------------------------------ if (currentSeasonData == null || currentSeasonData != download.Upload.Season) { currentSeasonData = download.Upload.Season; seasonNr = -1; Match m2 = new Regex("(?:season|staffel)\\s*(\\d+)", RegexOptions.IgnoreCase).Match(currentSeasonData.Title); if (m2.Success) { int.TryParse(m2.Groups[1].Value, out seasonNr); } } if (seasonNr == -1) { if (newNonSeasons.All(d => d.Title != download.Title)) { newNonSeasons.Add(download); } continue; } if (currentFavSeason == null || currentFavSeason.Number != seasonNr) { currentFavSeason = newSeasons.FirstOrDefault(favSeasonData => favSeasonData.Number == seasonNr) ?? new FavSeasonData() { Number = seasonNr, Show = this }; if (!newSeasons.Contains(currentFavSeason)) //season not yet added? { newSeasons.Add(currentFavSeason); } } int episodeNr = -1; MatchCollection mts = new Regex("S0{0,4}" + seasonNr + "\\.?E(\\d+)", RegexOptions.IgnoreCase).Matches(download.Title); MatchCollection mts_ep = new Regex("[^A-Z]E(\\d+)", RegexOptions.IgnoreCase).Matches(download.Title); MatchCollection mts_alt = new Regex("\\bE(\\d+)\\b", RegexOptions.IgnoreCase).Matches(download.Title); if (mts.Count == 1 && mts_ep.Count == 1) //if there is exactly one match for "S<xx>E<yy>" and there is no second "E<zz>" (e.g. S01E01-E12) { int.TryParse(mts[0].Groups[1].Value, out episodeNr); } else if (mts_alt.Count == 1) //if there's exactly one match for the alternative regex { int.TryParse(mts_alt[0].Groups[1].Value, out episodeNr); } if (episodeNr == -1) { if (currentFavSeason.NonEpisodes.All(d => d.Title != download.Title)) { currentFavSeason.NonEpisodes.Add(download); } continue; } FavEpisodeData currentFavEpisode = currentFavSeason.Episodes.FirstOrDefault(episodeData => episodeData.Number == episodeNr); if (currentFavEpisode == null) { currentFavEpisode = new FavEpisodeData(); currentFavEpisode.Season = currentFavSeason; currentFavEpisode.Number = episodeNr; bool existed = false; var oldSeason = Seasons.FirstOrDefault(s => s.Number == currentFavSeason.Number); if (oldSeason != null) { var oldEpisode = oldSeason.Episodes.FirstOrDefault(e => e.Number == currentFavEpisode.Number); if (oldEpisode != null) //we can copy old data to current episode { currentFavEpisode.Watched = oldEpisode.Watched; currentFavEpisode.Downloaded = oldEpisode.Downloaded; currentFavEpisode.EpisodeInformation = oldEpisode.EpisodeInformation; existed = true; } } if (notifications && !existed) { currentFavEpisode.NewEpisode = true; setNewEpisodes = true; } currentFavSeason.Episodes.Add(currentFavEpisode); currentFavEpisode.Downloads.Add(download); if (ProviderData != null && (currentFavEpisode.EpisodeInformation == null || reset)) { StaticInstance.ThreadPool.QueueWorkItem(() => { //currentFavEpisode.ReviewInfoReview = SjInfo.ParseSjDeSite(InfoUrl, currentFavEpisode.Season.Number, currentFavEpisode.Number); currentFavEpisode.EpisodeInformation = ProviderManager.GetProvider().GetEpisodeInformation(ProviderData, currentFavEpisode.Season.Number, currentFavEpisode.Number); }); } } else { FavEpisodeData oldEpisode = null; var oldSeason = Seasons.FirstOrDefault(s => s.Number == currentFavSeason.Number); if (oldSeason != null) { oldEpisode = oldSeason.Episodes.FirstOrDefault(e => e.Number == currentFavEpisode.Number); } if (currentFavEpisode.Downloads.All(d => d.Title != download.Title)) { if (notifications && (oldEpisode == null || (!oldEpisode.NewEpisode && oldEpisode.Downloads.All(d => d.Title != download.Title)))) { currentFavEpisode.NewUpdate = true; setNewUpdates = true; } currentFavEpisode.Downloads.Add(download); } } } if (reset) { Seasons.Clear(); foreach (var season in newSeasons) { Seasons.Add(season); } NonSeasons.Clear(); foreach (var nonSeason in newNonSeasons) { NonSeasons.Add(nonSeason); } } if (setNewEpisodes) { Notified = false; NewEpisodes = true; } if (setNewUpdates) { NewUpdates = true; } RecalcNumbers(); _mutexFilter.ReleaseMutex(); }
public void CreateSeason(Season season) { Seasons.Add(season); SaveChanges(); }
private void FillSeasons() { Seasons.Clear(); Seasons.Add(Season.Summer); Seasons.Add(Season.Winter); }
private void SelectFolderButton_Click(object sender, RoutedEventArgs e) { try { WriteOutput($"Opening folder picker...", OutputMessageLevel.Normal); busyIndicator.IsBusy = true; busyIndicator.BusyContent = "opening folder..."; busyIndicator.IsIndeterminate = true; if (!string.IsNullOrEmpty(Properties.Settings.Default.LastFolder)) { // Need to bump up one level from the last folder location var topDirectoryInfo = Directory.GetParent(Properties.Settings.Default.LastFolder); openFolderDialog.InitialDirectory = topDirectoryInfo.FullName; WriteOutput($"Starting at saved folder.", OutputMessageLevel.Normal); } else { WriteOutput($"No saved folder, starting at root.", OutputMessageLevel.Warning); } openFolderDialog.ShowDialog(); if (openFolderDialog.DialogResult != true) { WriteOutput($"Canceled folder selection.", OutputMessageLevel.Normal); return; } else { Properties.Settings.Default.LastFolder = openFolderDialog.FileName; Properties.Settings.Default.Save(); } Reset(); busyIndicator.BusyContent = $"searching for seasons..."; var seasonsResult = Directory.EnumerateDirectories(openFolderDialog.FileName).ToList(); Seasons.Clear(); foreach (var season in seasonsResult) { Seasons.Add(season); busyIndicator.BusyContent = $"added {season}"; } if (Seasons.Count == 0) { WriteOutput("No seasons detected, make sure there are subfolders with season number.", OutputMessageLevel.Warning); } else if (Seasons.Count == 1) { WriteOutput($"Opened '{System.IO.Path.GetFileName(openFolderDialog.FileName)}' ({Seasons.Count} season).", OutputMessageLevel.Success); } else { WriteOutput($"Opened '{System.IO.Path.GetFileName(openFolderDialog.FileName)}' ({Seasons.Count} seasons).", OutputMessageLevel.Success); } Analytics.TrackEvent("Video Folder Opened", new Dictionary <string, string> { { "Seasons", Seasons.Count.ToString(CultureInfo.InvariantCulture) } }); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); WriteOutput(ex.Message, OutputMessageLevel.Error); Crashes.TrackError(ex, new Dictionary <string, string> { { "Folder Open", "TV Show" } }); } finally { busyIndicator.BusyContent = ""; busyIndicator.IsBusy = false; busyIndicator.IsIndeterminate = false; } }
private void GenerateSeedData() { var oversHelper = new OversHelper(); var playerIdentityFinder = new PlayerIdentityFinder(); var playerInMatchStatisticsBuilder = new PlayerInMatchStatisticsBuilder(playerIdentityFinder, oversHelper); var seedDataGenerator = new SeedDataGenerator(oversHelper, new BowlingFiguresCalculator(oversHelper), playerIdentityFinder, new TeamFakerFactory(), new MatchLocationFakerFactory(), new SchoolFakerFactory()); using (var connection = ConnectionFactory.CreateDatabaseConnection()) { connection.Open(); var repo = new SqlServerIntegrationTestsRepository(connection, playerInMatchStatisticsBuilder); repo.CreateUmbracoBaseRecords(); var members = seedDataGenerator.CreateMembers(); foreach (var member in members) { repo.CreateMember(member); } ClubWithMinimalDetails = seedDataGenerator.CreateClubWithMinimalDetails(); repo.CreateClub(ClubWithMinimalDetails); Clubs.Add(ClubWithMinimalDetails); ClubWithOneTeam = seedDataGenerator.CreateClubWithMinimalDetails(); repo.CreateClub(ClubWithOneTeam); Clubs.Add(ClubWithOneTeam); var onlyTeamInClub = seedDataGenerator.CreateTeamWithMinimalDetails("Only team in the club"); ClubWithOneTeam.Teams.Add(onlyTeamInClub); onlyTeamInClub.Club = ClubWithOneTeam; repo.CreateTeam(onlyTeamInClub); Teams.Add(onlyTeamInClub); ClubWithTeamsAndMatchLocation = seedDataGenerator.CreateClubWithTeams(); MatchLocationForClub = seedDataGenerator.CreateMatchLocationWithMinimalDetails(); MatchLocationForClub.PrimaryAddressableObjectName = "Club PAON"; MatchLocationForClub.SecondaryAddressableObjectName = "Club SAON"; MatchLocationForClub.Locality = "Club locality"; MatchLocationForClub.Town = "Club town"; MatchLocationForClub.AdministrativeArea = "Club area"; var teamWithMatchLocation = ClubWithTeamsAndMatchLocation.Teams.First(x => !x.UntilYear.HasValue); teamWithMatchLocation.MatchLocations.Add(MatchLocationForClub); MatchLocationForClub.Teams.Add(teamWithMatchLocation); repo.CreateClub(ClubWithTeamsAndMatchLocation); Clubs.Add(ClubWithTeamsAndMatchLocation); foreach (var team in ClubWithTeamsAndMatchLocation.Teams) { repo.CreateTeam(team); foreach (var matchLocation in team.MatchLocations) { repo.CreateMatchLocation(matchLocation); repo.AddTeamToMatchLocation(team, matchLocation); MatchLocations.Add(matchLocation); } } Teams.AddRange(ClubWithTeamsAndMatchLocation.Teams); TeamWithMinimalDetails = seedDataGenerator.CreateTeamWithMinimalDetails("Team minimal"); repo.CreateTeam(TeamWithMinimalDetails); Teams.Add(TeamWithMinimalDetails); TeamWithFullDetails = seedDataGenerator.CreateTeamWithFullDetails("Team with full details"); repo.CreateTeam(TeamWithFullDetails); Teams.Add(TeamWithFullDetails); foreach (var matchLocation in TeamWithFullDetails.MatchLocations) { repo.CreateMatchLocation(matchLocation); foreach (var team in matchLocation.Teams) { if (team.TeamId != TeamWithFullDetails.TeamId) { repo.CreateTeam(team); Teams.Add(team); } repo.AddTeamToMatchLocation(team, matchLocation); } MatchLocations.Add(matchLocation); } repo.CreateCompetition(TeamWithFullDetails.Seasons[0].Season.Competition); Competitions.Add(TeamWithFullDetails.Seasons[0].Season.Competition); foreach (var season in TeamWithFullDetails.Seasons) { repo.CreateSeason(season.Season, season.Season.Competition.CompetitionId.Value); repo.AddTeamToSeason(season); Seasons.Add(season.Season); } MatchInThePastWithMinimalDetails = seedDataGenerator.CreateMatchInThePastWithMinimalDetails(); repo.CreateMatch(MatchInThePastWithMinimalDetails); Matches.Add(MatchInThePastWithMinimalDetails); MatchListings.Add(MatchInThePastWithMinimalDetails.ToMatchListing()); MatchInTheFutureWithMinimalDetails = seedDataGenerator.CreateMatchInThePastWithMinimalDetails(); MatchInTheFutureWithMinimalDetails.StartTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTimeOffset.UtcNow.AccurateToTheMinute().AddMonths(1), UkTimeZone()); repo.CreateMatch(MatchInTheFutureWithMinimalDetails); Matches.Add(MatchInTheFutureWithMinimalDetails); MatchListings.Add(MatchInTheFutureWithMinimalDetails.ToMatchListing()); MatchInThePastWithFullDetails = seedDataGenerator.CreateMatchInThePastWithFullDetails(members); repo.CreateMatchLocation(MatchInThePastWithFullDetails.MatchLocation); var playersForMatchInThePastWithFullDetails = playerIdentityFinder.PlayerIdentitiesInMatch(MatchInThePastWithFullDetails); MatchInThePastWithFullDetails.Teams[0].Team.UntilYear = 2020; foreach (var team in MatchInThePastWithFullDetails.Teams) { repo.CreateTeam(team.Team); } foreach (var player in playersForMatchInThePastWithFullDetails) { repo.CreatePlayer(player.Player); repo.CreatePlayerIdentity(player); } repo.CreateCompetition(MatchInThePastWithFullDetails.Season.Competition); repo.CreateSeason(MatchInThePastWithFullDetails.Season, MatchInThePastWithFullDetails.Season.Competition.CompetitionId.Value); repo.CreateMatch(MatchInThePastWithFullDetails); Teams.AddRange(MatchInThePastWithFullDetails.Teams.Select(x => x.Team)); Competitions.Add(MatchInThePastWithFullDetails.Season.Competition); Seasons.Add(MatchInThePastWithFullDetails.Season); MatchLocations.Add(MatchInThePastWithFullDetails.MatchLocation); Matches.Add(MatchInThePastWithFullDetails); MatchListings.Add(MatchInThePastWithFullDetails.ToMatchListing()); PlayerIdentities.AddRange(playerIdentityFinder.PlayerIdentitiesInMatch(MatchInThePastWithFullDetails)); MatchInThePastWithFullDetails.History.AddRange(new[] { new AuditRecord { Action = AuditAction.Create, ActorName = nameof(SqlServerDataSourceFixture), AuditDate = DateTimeOffset.UtcNow.AccurateToTheMinute().AddMonths(-1), EntityUri = MatchInThePastWithFullDetails.EntityUri }, new AuditRecord { Action = AuditAction.Update, ActorName = nameof(SqlServerDataSourceFixture), AuditDate = DateTimeOffset.UtcNow.AccurateToTheMinute(), EntityUri = MatchInThePastWithFullDetails.EntityUri } }); foreach (var audit in MatchInThePastWithFullDetails.History) { repo.CreateAudit(audit); } TournamentInThePastWithMinimalDetails = seedDataGenerator.CreateTournamentInThePastWithMinimalDetails(); repo.CreateTournament(TournamentInThePastWithMinimalDetails); Tournaments.Add(TournamentInThePastWithMinimalDetails); MatchListings.Add(TournamentInThePastWithMinimalDetails.ToMatchListing()); TournamentInTheFutureWithMinimalDetails = seedDataGenerator.CreateTournamentInThePastWithMinimalDetails(); TournamentInTheFutureWithMinimalDetails.StartTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTimeOffset.UtcNow.AccurateToTheMinute().AddMonths(1), UkTimeZone()); repo.CreateTournament(TournamentInTheFutureWithMinimalDetails); Tournaments.Add(TournamentInTheFutureWithMinimalDetails); MatchListings.Add(TournamentInTheFutureWithMinimalDetails.ToMatchListing()); TournamentInThePastWithFullDetails = seedDataGenerator.CreateTournamentInThePastWithFullDetails(members); Teams.AddRange(TournamentInThePastWithFullDetails.Teams.Select(x => x.Team)); MatchInThePastWithFullDetails.Teams[0].Team.UntilYear = 2020; foreach (var team in TournamentInThePastWithFullDetails.Teams) { repo.CreateTeam(team.Team); } MatchLocations.Add(TournamentInThePastWithFullDetails.TournamentLocation); repo.CreateMatchLocation(TournamentInThePastWithFullDetails.TournamentLocation); repo.CreateTournament(TournamentInThePastWithFullDetails); foreach (var team in TournamentInThePastWithFullDetails.Teams) { repo.AddTeamToTournament(team, TournamentInThePastWithFullDetails); } foreach (var season in TournamentInThePastWithFullDetails.Seasons) { repo.CreateCompetition(season.Competition); Competitions.Add(season.Competition); repo.CreateSeason(season, season.Competition.CompetitionId.Value); repo.AddTournamentToSeason(TournamentInThePastWithFullDetails, season); Seasons.Add(season); } Tournaments.Add(TournamentInThePastWithFullDetails); MatchListings.Add(TournamentInThePastWithFullDetails.ToMatchListing()); for (var i = 0; i < 5; i++) { var tournamentMatch = seedDataGenerator.CreateMatchInThePastWithMinimalDetails(); tournamentMatch.Tournament = TournamentInThePastWithFullDetails; tournamentMatch.StartTime = TournamentInThePastWithFullDetails.StartTime.AddHours(i); tournamentMatch.OrderInTournament = i + 1; repo.CreateMatch(tournamentMatch); Matches.Add(tournamentMatch); TournamentMatchListings.Add(tournamentMatch.ToMatchListing()); } TournamentInThePastWithFullDetails.History.AddRange(new[] { new AuditRecord { Action = AuditAction.Create, ActorName = nameof(SqlServerDataSourceFixture), AuditDate = DateTimeOffset.UtcNow.AccurateToTheMinute().AddMonths(-2), EntityUri = TournamentInThePastWithFullDetails.EntityUri }, new AuditRecord { Action = AuditAction.Update, ActorName = nameof(SqlServerDataSourceFixture), AuditDate = DateTimeOffset.UtcNow.AccurateToTheMinute().AddDays(-7), EntityUri = TournamentInThePastWithFullDetails.EntityUri } }); foreach (var audit in TournamentInThePastWithFullDetails.History) { repo.CreateAudit(audit); } MatchInThePastWithFullDetailsAndTournament = seedDataGenerator.CreateMatchInThePastWithFullDetails(members); MatchInThePastWithFullDetailsAndTournament.Tournament = TournamentInThePastWithMinimalDetails; MatchInThePastWithFullDetailsAndTournament.Season.FromYear = MatchInThePastWithFullDetailsAndTournament.Season.UntilYear = 2018; repo.CreateMatchLocation(MatchInThePastWithFullDetailsAndTournament.MatchLocation); foreach (var team in MatchInThePastWithFullDetailsAndTournament.Teams) { repo.CreateTeam(team.Team); } var playersForMatchInThePastWithFullDetailsAndTournament = playerIdentityFinder.PlayerIdentitiesInMatch(MatchInThePastWithFullDetailsAndTournament); foreach (var player in playersForMatchInThePastWithFullDetailsAndTournament) { repo.CreatePlayer(player.Player); repo.CreatePlayerIdentity(player); } repo.CreateCompetition(MatchInThePastWithFullDetailsAndTournament.Season.Competition); repo.CreateSeason(MatchInThePastWithFullDetailsAndTournament.Season, MatchInThePastWithFullDetailsAndTournament.Season.Competition.CompetitionId.Value); repo.CreateMatch(MatchInThePastWithFullDetailsAndTournament); Teams.AddRange(MatchInThePastWithFullDetailsAndTournament.Teams.Select(x => x.Team)); Competitions.Add(MatchInThePastWithFullDetailsAndTournament.Season.Competition); MatchLocations.Add(MatchInThePastWithFullDetailsAndTournament.MatchLocation); Matches.Add(MatchInThePastWithFullDetailsAndTournament); TournamentMatchListings.Add(MatchInThePastWithFullDetailsAndTournament.ToMatchListing()); Seasons.Add(MatchInThePastWithFullDetailsAndTournament.Season); PlayerIdentities.AddRange(playerIdentityFinder.PlayerIdentitiesInMatch(MatchInThePastWithFullDetailsAndTournament)); CompetitionWithMinimalDetails = seedDataGenerator.CreateCompetitionWithMinimalDetails(); repo.CreateCompetition(CompetitionWithMinimalDetails); Competitions.Add(CompetitionWithMinimalDetails); CompetitionWithFullDetails = seedDataGenerator.CreateCompetitionWithFullDetails(); repo.CreateCompetition(CompetitionWithFullDetails); foreach (var season in CompetitionWithFullDetails.Seasons) { repo.CreateSeason(season, CompetitionWithFullDetails.CompetitionId.Value); Seasons.Add(season); } Competitions.Add(CompetitionWithFullDetails); var competitionForSeason = seedDataGenerator.CreateCompetitionWithMinimalDetails(); competitionForSeason.UntilYear = 2021; SeasonWithMinimalDetails = seedDataGenerator.CreateSeasonWithMinimalDetails(competitionForSeason, 2020, 2020); competitionForSeason.Seasons.Add(SeasonWithMinimalDetails); repo.CreateCompetition(competitionForSeason); repo.CreateSeason(SeasonWithMinimalDetails, competitionForSeason.CompetitionId.Value); Competitions.Add(competitionForSeason); Seasons.Add(SeasonWithMinimalDetails); SeasonWithFullDetails = seedDataGenerator.CreateSeasonWithFullDetails(competitionForSeason, 2021, 2021, seedDataGenerator.CreateTeamWithMinimalDetails("Team 1 in season"), seedDataGenerator.CreateTeamWithMinimalDetails("Team 2 in season")); competitionForSeason.Seasons.Add(SeasonWithFullDetails); Teams.AddRange(SeasonWithFullDetails.Teams.Select(x => x.Team)); foreach (var team in SeasonWithFullDetails.Teams) { repo.CreateTeam(team.Team); } repo.CreateSeason(SeasonWithFullDetails, competitionForSeason.CompetitionId.Value); foreach (var team in SeasonWithFullDetails.Teams) { repo.AddTeamToSeason(team); } Seasons.Add(SeasonWithFullDetails); MatchLocationWithMinimalDetails = seedDataGenerator.CreateMatchLocationWithMinimalDetails(); repo.CreateMatchLocation(MatchLocationWithMinimalDetails); MatchLocations.Add(MatchLocationWithMinimalDetails); MatchLocationWithFullDetails = seedDataGenerator.CreateMatchLocationWithFullDetails(); repo.CreateMatchLocation(MatchLocationWithFullDetails); Teams.AddRange(MatchLocationWithFullDetails.Teams); MatchLocations.Add(MatchLocationWithFullDetails); foreach (var team in Teams.Where(t => t.Club == null || t.Club.ClubId == ClubWithOneTeam.ClubId)) { TeamListings.Add(team.ToTeamListing()); } foreach (var club in Clubs.Where(c => c.Teams.Count == 0 || c.Teams.Count > 1)) { TeamListings.Add(club.ToTeamListing()); } for (var i = 0; i < 30; i++) { var competition = seedDataGenerator.CreateCompetitionWithMinimalDetails(); repo.CreateCompetition(competition); Competitions.Add(competition); var matchLocation = seedDataGenerator.CreateMatchLocationWithMinimalDetails(); repo.CreateMatchLocation(matchLocation); MatchLocations.Add(matchLocation); var match = seedDataGenerator.CreateMatchInThePastWithMinimalDetails(); match.MatchLocation = matchLocation; match.StartTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTimeOffset.UtcNow.AccurateToTheMinute().AddMonths(i - 15), UkTimeZone()); match.MatchType = i % 2 == 0 ? MatchType.FriendlyMatch : MatchType.LeagueMatch; match.PlayerType = i % 3 == 0 ? PlayerType.Mixed : PlayerType.Ladies; match.Comments = seedDataGenerator.CreateComments(i, members); repo.CreateMatch(match); Matches.Add(match); MatchListings.Add(match.ToMatchListing()); var tournament = seedDataGenerator.CreateTournamentInThePastWithMinimalDetails(); tournament.TournamentLocation = matchLocation; tournament.StartTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTimeOffset.UtcNow.AccurateToTheMinute().AddMonths(i - 20).AddDays(5), UkTimeZone()); tournament.Comments = seedDataGenerator.CreateComments(i, members); repo.CreateTournament(tournament); Tournaments.Add(tournament); MatchListings.Add(tournament.ToMatchListing()); } } }