コード例 #1
0
        public async Task <string> HandleInvitation(HandleInvitationDto request, CancellationToken cancellationToken)
        {
            Project selectedProject = await _projectRepository.Get(request.ProjectId, cancellationToken);

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

            Invitation toBeRemovedInvitation =
                await _projectRepository.GetInvitation(request.ProjectId, request.CollaboratorId, request.OwnerId);

            if (toBeRemovedInvitation == null)
            {
                return(ErrorMessages.NonexistentInvitation);
            }

            await _projectRepository.RemoveInvitation(toBeRemovedInvitation);

            if (request.Accepted == 1)
            {
                ProjectUser projectUserLink =
                    ProjectUser.CreateProjectUser(request.ProjectId, request.CollaboratorId, selectedProject);
                await _projectRepository.AddProjectUser(projectUserLink, cancellationToken);
            }

            return(SuccessMessages.Success);
        }
コード例 #2
0
        public async Task <ActionResult> HandleInvitation(HandleInvitationDto request, CancellationToken cancellationToken)
        {
            string response = await _projectService.HandleInvitation(request, cancellationToken);

            if (response == SuccessMessages.Success)
            {
                return(Ok(response));
            }
            else
            {
                return(BadRequest(response));
            }
        }