Exemplo n.º 1
0
        public static JObject ToDto(this PatientResult patient)
        {
            var result = ToDto((PersonResult)patient);

            result.Add("niss", patient.Niss);
            return(result);
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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);
        }