Esempio n. 1
0
        public IActionResult CreateProject(Guid freelancerId, [FromBody] CreateProjectDto model)
        {
            if (ModelState.IsValid)
            {
                var userId = new Guid(this.User.FindFirstValue(ClaimTypes.NameIdentifier));

                if (freelancerId == userId)
                {
                    var projectRep = _WorkRepository.CreateProject(freelancerId, model.Title);
                    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());
        }