public async Task Execute(IJobExecutionContext context) { _logger.LogInformation("Start CalendarJob"); try { var teamMates = (await _alertOwnerService.GetTeamMates()).ToList(); var oldCalendar = (await _alertOwnerService.GetCalendar(teamMates)).ToList(); var patronDays = await _alertOwnerService.GetPatronDays(); var shiftService = _shiftsService .AddPatronDays(patronDays); IEnumerable <Shift> calendar; if (oldCalendar.Any()) { calendar = shiftService .Build(oldCalendar) .ToList(); } else { calendar = shiftService .Build(teamMates) .ToList(); } await _alertOwnerService.ClearCalendar(); await _alertOwnerService.WriteCalendar(calendar); await _httpClient.Notify("Ciao <!channel> e' uscito il nuovo calendario dei turni:"); await _httpClient.Notify(calendar.Select(shift => $"{_converter.FormatValueAsString(shift.Schedule)} - {shift.TeamMate.Name}")); } catch (Exception e) { _logger.LogError(e, $"{e.Message}"); } _logger.LogInformation("CalendarJob Completed"); }