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); }
public async Task <ProjectDto> CreateProject(CreateProjectDto request, CancellationToken cancellationToken) { Project createdProject = Project.CreateProject(request.OwnerId, request.Name, request.Description, request.State); await _projectRepository.Add(createdProject, cancellationToken); ProjectUser projectUserLink = ProjectUser.CreateProjectUser(createdProject.Id, request.OwnerId, createdProject); await _projectRepository.AddProjectUser(projectUserLink, cancellationToken); foreach (string technologyName in request.Technologies) { Technology technology = await _projectRepository.GetTechnologyByName(technologyName); await _projectRepository.AddProjectTechnology(createdProject, technology, cancellationToken); } return(_mapper.Map <ProjectDto>(createdProject)); }