Beispiel #1
0
        public async Task Execute(IJobExecutionContext context)
        {
            DateTime[] actualMenuDates = await _botRepository.GetActualMenuDates();

            DateTime[] newMenuDates = await _foodRepository.NewMenuDates(actualMenuDates.Max());

            if (newMenuDates.Length > 0)
            {
                await _botRepository.SaveActualMenuDates(newMenuDates);

                string message = $"Меню на {newMenuDates.Min().ToShortDateString()} - {newMenuDates.Max().ToShortDateString()} выложено";
                await _messageSender.SendAsync(
                    new[]
                {
                    new Destination {
                        Messenger = Messenger.Slack, ChannelId = _appConfig.SlackOfficeChat
                    },
                    new Destination {
                        Messenger = Messenger.Skype, ChannelId = _appConfig.SkypeOfficeChat
                    }
                },
                    new BotResponse { Text = message });
            }
        }