public async Task AddJobsToChatWithExistingSchedule(ChatId chat, ScheduleUpdateModel model) { string chatId = chat.Identifier.ToString(); var dtoAlerts = model.Alerts; string newName = model.NewName; int scheduleId = await _chatRepo.GetScheduleIdOfChat(chatId); int initialCount = await _scheduleRepo.GetAlertsCountOf(scheduleId); List <string> jobIds = SetupJobs(dtoAlerts, chatId, initialCount); try { var alerts = ConvertAlerts(dtoAlerts); SetJobIdsToAlerts(jobIds, alerts); await ApplyNewName(newName, scheduleId); await _scheduleRepo.AddAlertsToSchedule(alerts, scheduleId); } catch { DeleteCreatedJobs(jobIds); throw; } }