public async Task <IActionResult> FollowProject(int projectId) { User user = await HttpContext.GetContextUser(userService) .ConfigureAwait(false); if (await userService.FindAsync(user.Id) == null) { ProblemDetails problem = new ProblemDetails { Title = "Failed getting the user account.", Detail = "The database does not contain a user with this user id.", Instance = "B778C55A-D41E-4101-A7A0-F02F76E5A6AE" }; return(NotFound(problem)); } if (userProjectService.CheckIfUserFollows(user.Id, projectId)) { ProblemDetails problem = new ProblemDetails { Title = "User already follows this project", Detail = "You are already following this project.", Instance = "27D14082-9906-4EB8-AE4C-65BAEC0BB4FD" }; return(Conflict(problem)); } Project project = await projectService.FindAsync(projectId); if (await projectService.FindAsync(projectId) == null) { ProblemDetails problem = new ProblemDetails { Title = "Failed getting the project.", Detail = "The database does not contain a project with this project id.", Instance = "57C13F73-6D22-41F3-AB05-0CCC1B3C8328" }; return(NotFound(problem)); } UserProject userProject = new UserProject(project, user); userProjectService.Add(userProject); userProjectService.Save(); return(Ok(mapper.Map <UserProject, UserProjectResourceResult>(userProject))); }