private async Task <Guid> CreateOutlookMeeting(
            CreateInvitationCommand request,
            IReadOnlyCollection <BuilderParticipant> meetingParticipants,
            Invitation invitation)
        {
            foreach (var meetingParticipant in meetingParticipants)
            {
                _logger.LogInformation($"Adding {meetingParticipant.Person.AzureUniqueId} - {meetingParticipant.Person.Mail} to invitation {invitation.Id}");
            }

            var organizer = await _personRepository.GetByOidAsync(_currentUserProvider.GetCurrentUserOid());

            var meeting = await _meetingClient.CreateMeetingAsync(meetingBuilder =>
            {
                var baseUrl = InvitationHelper.GetBaseUrl(_meetingOptions.CurrentValue.PcsBaseUrl, _plantProvider.Plant);

                meetingBuilder
                .StandaloneMeeting(InvitationHelper.GenerateMeetingTitle(invitation), request.Location)
                .StartsOn(request.StartTime, request.EndTime)
                .WithTimeZone("UTC")
                .WithParticipants(meetingParticipants)
                .WithClassification(MeetingClassification.Open)
                .EnableOutlookIntegration()
                .WithInviteBodyHtml(InvitationHelper.GenerateMeetingDescription(invitation, baseUrl, organizer));
            });

            return(meeting.Id);
        }
        public async Task <Result <string> > Handle(EditInvitationCommand request, CancellationToken cancellationToken)
        {
            var meetingParticipants = new List <BuilderParticipant>();
            var invitation          = await _invitationRepository.GetByIdAsync(request.InvitationId);

            var mcPkgScope = await GetMcPkgScopeAsync(request.UpdatedMcPkgScope, invitation.ProjectName);

            var commPkgScope = await GetCommPkgScopeAsync(request.UpdatedCommPkgScope, invitation.ProjectName);

            meetingParticipants = await UpdateParticipants(meetingParticipants, request.UpdatedParticipants, invitation);

            invitation.EditIpo(
                request.Title,
                request.Description,
                request.Type,
                request.StartTime,
                request.EndTime,
                request.Location,
                mcPkgScope,
                commPkgScope);

            invitation.SetRowVersion(request.RowVersion);
            try
            {
                var baseUrl =
                    InvitationHelper.GetBaseUrl(_meetingOptions.CurrentValue.PcsBaseUrl, _plantProvider.Plant);

                var organizer = await _personRepository.GetByIdAsync(invitation.CreatedById);

                await _meetingClient.UpdateMeetingAsync(invitation.MeetingId, builder =>
                {
                    builder.UpdateLocation(request.Location);
                    builder.UpdateMeetingDate(request.StartTime, request.EndTime);
                    builder.UpdateTimeZone("UTC");
                    builder.UpdateParticipants(meetingParticipants);
                    builder.UpdateInviteBodyHtml(InvitationHelper.GenerateMeetingDescription(invitation, baseUrl, organizer));
                });
            }
            catch (Exception e)
            {
                throw new Exception("Error: Could not update outlook meeting.", e);
            }

            await _unitOfWork.SaveChangesAsync(cancellationToken);

            return(new SuccessResult <string>(invitation.RowVersion.ConvertToString()));
        }