public async Task <IActionResult> Post(AppointmentDTO dto) { if (dto == null) { return(BadRequest($"The {nameof(dto)} parameter cannot be null.")); } if (dto.Patient == null) { return(BadRequest($"The {nameof(dto.Patient)} property of the {typeof(AppointmentDTO)} parameter cannot be null.")); } if (!await _externalPatientApiService.PatientExists(dto.Patient)) { return(BadRequest("No patient entity matching the specified personal details was found.")); } var model = await _appointmentService.CreateAsync(dto); if (model != null) { return(CreatedAtAction("Get", new { model.Id }, model)); } return(BadRequest("An error occurred creating the appointment.")); }
public async Task <ActionResult <AppointmentDto> > Post([FromBody] AppointmentCreateDto appointmentCreateDto) { AppointmentDto createdAppointment = await _appointmentService.CreateAsync(appointmentCreateDto); return(CreatedAtAction(nameof(GetById), new { id = createdAppointment.Id }, createdAppointment)); }