public async Task <bool> ParticipantWithIdExistsAsync(ParticipantsForCommand participant, int invitationId, CancellationToken cancellationToken) { if (participant.InvitedPerson is InvitedPersonForEditCommand editPerson) { if (editPerson.Id.HasValue && !await ParticipantExistsAsync(editPerson.Id.Value, invitationId, cancellationToken)) { return(false); } } if (participant.InvitedExternalEmail is InvitedExternalEmailForEditCommand externalEmail) { if (externalEmail.Id.HasValue && !await ParticipantExistsAsync(externalEmail.Id.Value, invitationId, cancellationToken)) { return(false); } } if (participant.InvitedFunctionalRole is InvitedFunctionalRoleForEditCommand functionalRole) { if (functionalRole.Id.HasValue && !await ParticipantExistsAsync(functionalRole.Id.Value, invitationId, cancellationToken)) { return(false); } foreach (var person in functionalRole.EditPersons) { if (person.Id.HasValue && !await ParticipantExistsAsync(person.Id.Value, invitationId, cancellationToken)) { return(false); } } } return(true); }
private bool IsValidFunctionalRoleParticipant(ParticipantsForCommand participant) { if (string.IsNullOrEmpty(participant.InvitedFunctionalRole.Code)) { return(false); } if (participant.InvitedFunctionalRole.InvitedPersons.Any(person => !IsValidPerson(person))) { return(false); } return(participant.InvitedPerson == null && participant.InvitedExternalEmail == null); }
private bool IsValidPersonParticipant(ParticipantsForCommand participant) => IsValidPerson(participant.InvitedPerson) && participant.InvitedExternalEmail == null && participant.InvitedFunctionalRole == null;
private bool IsValidExternalParticipant(ParticipantsForCommand participant) { var isValidEmail = new EmailAddressAttribute().IsValid(participant.InvitedExternalEmail.Email); return(isValidEmail && participant.InvitedPerson == null && participant.InvitedFunctionalRole == null); }