public static JObject ToDto(this PatientResult patient) { var result = ToDto((PersonResult)patient); result.Add("niss", patient.Niss); return(result); }
public async Task <IActionResult> Register([FromBody] Patient patient) { if (ModelState.IsValid) { PatientResult patientResult = await _registerPatient.Register(patient.FirstName, patient.Species, patient.Breed, patient.ClientId); return(Ok()); } return(BadRequest(ModelState)); }
public async Task <PatientResult> Register(string firstName, string species, string breed, Guid clientId) { bool clientExists = await _clientReadOnlyRepository.ExistsById(clientId); if (!clientExists) { throw new ClientNotFoundException($"The client {clientId} does not exists."); } Patient patient = new Patient(firstName, breed, species, clientId); await _patientWriteOnlyRepository.Add(patient); PatientResult patientResult = new PatientResult(patient); return(patientResult); }