Exemplo n.º 1
0
        public async Task <PatientModel> Handle(CreatePatientAllergyCommand request, CancellationToken cancellationToken)
        {
            await _repository.CreatePatientAllergyAsync(request.PatientId, new Allergy()
            {
                Id = request.AllergyId
            });

            var patient = await _repository.GetPatientByIdAsync(request.PatientId);

            return(new PatientModel()
            {
                Id = patient.Id,
                Names = patient.Names,
                Surnames = patient.Surnames,
                Age = patient.Age,
                Birthday = patient.Birthday,
                Allergies = patient.Allergies.Select(a => new AllergyModel()
                {
                    Id = a.Id,
                    Name = a.Name
                })
            });
        }