public async Task <ActionResult <TicketDTO> > PostAsync(int projectId, TicketDTO ticket) { if (ticket is null) { return(BadRequest()); } if (!await _repo.ProjectExistsAsync(projectId)) { return(NotFound("Project not found")); } if (ticket.Submitter is null || !await _repo.UserExistsAsync(ticket.Submitter.UserId)) { return(NotFound("Submitter not found")); } if (ticket.Dev != null && ticket.Dev.UserId != 0 && !await _repo.UserExistsAsync(ticket.Dev.UserId)) { return(NotFound("Dev not found")); } if (ticket.Priority is null || !await _repo.PriorityExistsAsync(ticket.Priority)) { return(NotFound("Priority not found")); } if (ticket.Status is null || !await _repo.StatusExistsAsync(ticket.Status)) { return(NotFound("Status not found")); } if (ticket.Type is null || !await _repo.TypeExistsAsync(ticket.Type)) { return(NotFound("Type not found")); } var newId = await _repo.CreateTicketAsync(projectId, ticket); return(CreatedAtAction( nameof(GetAsync), new { ticketId = newId }, await _repo.ReadTicketAsync(newId) )); }