Skip to content

Commit fd2639f

Browse files
Angel Mendezdanielluo-msft
authored andcommitted
Updated the PostJobHandler to leverage the DestinationAttributesUpdaterRepository for updating the attributes of new jobs.
1 parent 56d94c4 commit fd2639f

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

Service/GroupMembershipManagement/Hosts/WebApi/Services.WebApi/PostJobHandler.cs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,17 @@ protected override async Task<PostJobResponse> ExecuteCoreAsync(PostJobRequest r
4949
}
5050

5151
var destinationName = await _graphGroupRepository.GetGroupNameAsync(destinationId);
52-
newSyncJobEntity.DestinationName = new DestinationName { Name = destinationName };
52+
var ownersDictionary = await _graphGroupRepository.GetDestinationOwnersAsync(new List<Guid> { destinationId });
5353

54-
var destinationIds = new List<Guid> { destinationId };
55-
var ownersDictionary = await _graphGroupRepository.GetDestinationOwnersAsync(destinationIds);
56-
57-
var destinationOwners = new List<DestinationOwner>();
54+
var newSyncJobId = await _syncJobRepository.CreateSyncJobAsync(newSyncJobEntity);
5855

59-
if (ownersDictionary.TryGetValue(destinationId, out List<Guid> ownerGuids))
56+
var destinationAttributes = new DestinationAttributes
6057
{
61-
foreach (var ownerGuid in ownerGuids)
62-
{
63-
var destinationOwner = new DestinationOwner
64-
{
65-
ObjectId = ownerGuid
66-
};
67-
destinationOwners.Add(destinationOwner);
68-
}
69-
}
70-
71-
newSyncJobEntity.DestinationOwners = destinationOwners;
72-
73-
var newSyncJobId = await _syncJobRepository.CreateSyncJobAsync(newSyncJobEntity);
58+
Id = newSyncJobId,
59+
Name = destinationName,
60+
Owners = ownersDictionary.GetValueOrDefault(destinationId)
61+
};
62+
await _destinationAttributesRepository.UpdateAttributes(destinationAttributes);
7463

7564
if (newSyncJobId != Guid.Empty)
7665
{

0 commit comments

Comments
 (0)