예제 #1
0
        public IActionResult AddMeToProject(Guid freelancerId, [FromBody] AddMeToProjectDto model)
        {
            if (ModelState.IsValid)
            {
                var userId = new Guid(this.User.FindFirstValue(ClaimTypes.NameIdentifier));
                if (freelancerId == userId)
                {
                    var projectRep = _WorkRepository.AddFreelacerToProject(freelancerId, new Guid(model.ProjectId));
                    if (!projectRep.Any())
                    {
                        return(NotFound());
                    }

                    var projects = projectRep.Select(a => new ProjectDto
                    {
                        ProjetId  = a.Id,
                        Title     = a.Title,
                        startDate = a.StartDate
                    });
                    return(Ok(projects));
                }
            }
            return(BadRequest());
        }