public async Task <ScheduleCheckResult> Get() { foreach (Models.ScheduleSyncSpec s in _dbContext.ScheduleSyncSpecs.ToArray()) { if (s.Expires < DateTime.Today) { _dbContext.Remove(s); continue; } TeamSnapApi api = new TeamSnapApi(s.TeamSnapToken); HashSet <DateTime> exclusions = new HashSet <DateTime>(_dbContext.ScheduleSyncSpecExclusions.Where(x => x.ScheduleSyncSpecID == s.ID).Select(x => x.ExcludedDate)); IEnumerable <ScheduleComparer.CompareResult> res = await new ScheduleComparer(api, _parser, s.TeamSnapTeamId, s.TwinRinkTeamName, exclusions).RunCompareAsync(); if (res.Any()) { await BuildAndSendEmail(s, res); } s.LastChecked = DateTime.UtcNow; } await _dbContext.SaveChangesAsync(); return(new ScheduleCheckResult()); }
public ScheduleComparer(TeamSnapApi tsApi, TwinRinksScheduleParserService trApi, long teamSnapTeamId, string twinRinksTeam, HashSet <DateTime> exclusions = null, CompareOptions options = null) { if (string.IsNullOrWhiteSpace(twinRinksTeam)) { throw new System.ArgumentException("message", nameof(twinRinksTeam)); } this.tsApi = tsApi ?? throw new System.ArgumentNullException(nameof(tsApi)); this.trApi = trApi ?? throw new System.ArgumentNullException(nameof(trApi)); this.teamSnapTeamId = teamSnapTeamId; this.twinRinksTeam = twinRinksTeam; this.exclusions = exclusions; Options = options ?? new CompareOptions(); }
public CreateModel(TeamSnapApi tsApi, TwinRinksScheduleParserService parser, Models.TwinRinksHelperContext dbContext) { this.tsApi = tsApi ?? throw new System.ArgumentNullException(nameof(tsApi)); this.parser = parser ?? throw new System.ArgumentNullException(nameof(parser)); _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); }
public CompareScheduleModel(TeamSnapApi tsApi, TwinRinksScheduleParserService parser) { this.tsApi = tsApi ?? throw new System.ArgumentNullException(nameof(tsApi)); this.parser = parser ?? throw new System.ArgumentNullException(nameof(parser)); }
public PrintTeamStickers(TeamSnapApi tsApi, TeamStickerPrintingService ts) { _teamStickerService = ts ?? throw new System.ArgumentNullException(nameof(ts)); this.tsApi = tsApi ?? throw new System.ArgumentNullException(nameof(tsApi)); }
public CreateEventsModel(TeamSnapApi tsApi, TwinRinksScheduleParserService trApi) { this.tsApi = tsApi ?? throw new System.ArgumentNullException(nameof(tsApi)); this.trApi = trApi ?? throw new System.ArgumentNullException(nameof(trApi)); }