Exemple #1
0
        public async Task Handle(Activity activity)
        {
            var channelData      = activity.GetChannelData <TeamsChannelData>();
            var isGroupChat      = channelData.Channel == null;
            var teamId           = isGroupChat ? string.Empty : channelData.Team.Id;
            var channelId        = isGroupChat ? activity.Conversation.Id : channelData.Channel.Id;
            var draftCompetition = await _competitionService.CreateDraftCompetition(
                activity.ServiceUrl,
                Guid.Parse(channelData.Tenant.Id),
                teamId,
                channelId,
                activity.Locale,
                activity.GetOffset().TotalHours,
                activity.From.Name,
                activity.From.AadObjectId);

            var activityForDraft = _activityBuilder.CreateMainActivity(draftCompetition);

            using (var botClient = _botClientFactory.CreateBotClient(activity.ServiceUrl))
            {
                var mainMessage = await botClient.SendToConversationAsync(activityForDraft);

                await _competitionService.UpdateMainActivity(draftCompetition.Id, mainMessage.Id);
            }
        }