예제 #1
0
        public async Task <string> CreateInvitation(CreateInvitationDto request, CancellationToken cancellationToken)
        {
            Project selectedProject = await _projectRepository.Get(request.ProjectId, cancellationToken);

            if (selectedProject == null)
            {
                return(ErrorMessages.InvalidProjectId);
            }

            CreateInvitationDtoValidator dtoValidator = new CreateInvitationDtoValidator(_projectRepository);
            var validationResult = await dtoValidator.ValidateAsync(request, cancellationToken);

            if (validationResult.IsValid == false)
            {
                return(validationResult.ToString());
            }

            Invitation newInvitation = Invitation.CreateInvitation(request.ProjectId, selectedProject, request.CollaboratorId, request.OwnerId, request.InvitationType);
            await _projectRepository.AddInvitation(newInvitation, cancellationToken);

            return("success");
        }