Skip to content

Commit

Permalink
Merge branch 'feature/contact-remove-im' into feature/2.6.0-union
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-zhaolei committed Nov 30, 2024
2 parents 1204c77 + a8662fb commit 31ae4a6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/CAServer.Application/Contacts/ContactAppService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public async Task<ContactResultDto> CreateAsync(CreateUpdateContactDto input)

await CheckAddressAsync(userId, input.Addresses, input.RelationId);
var contactDto = await GetContactDtoAsync(input);

await CheckContactAsync(contactDto);
var contactGrain = _clusterClient.GetGrain<IContactGrain>(GuidGenerator.Create());
var result =
Expand Down Expand Up @@ -127,13 +127,20 @@ public async Task<ContactResultDto> UpdateAsync(Guid id, CreateUpdateContactDto
}

var contact = contactResult.Data;
if (contact.Addresses != null && contact.Addresses.Count > 1 && input.Addresses != null &&
input.Addresses.Count == 1)
var isUpdate = false;
if (contact.Addresses != null && contact.Addresses.Count > 1 && input.Addresses != null)
{
throw new UserFriendlyException("can not modify address");
if (input.Addresses.Count == 1)
throw new UserFriendlyException("can not modify address");

if (!input.Addresses.Select(t => t.Address).Distinct()
.Except(contact.Addresses.Select(t => t.Address).Distinct()).Any()
)
{
isUpdate = true;
}
}

var isUpdate = false;
if (contact.Addresses != null && contact.Addresses.Count == 1 && input.Addresses != null &&
input.Addresses.Count == 1)
{
Expand Down

0 comments on commit 31ae4a6

Please sign in to comment.