Пример #1
0
        public async Task <PatientModel> Handle(CreatePatientCommand request, CancellationToken cancellationToken)
        {
            long resultId = await _repository.CreatePatientAsync(new Patient()
            {
                Names     = request.Names,
                Surnames  = request.Surnames,
                Age       = request.Age,
                Birthday  = request.Birthday,
                CreatedBy = "APPLICATION"
            });

            var patient = await _repository.GetPatientByIdAsync(resultId);

            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
                })
            });
        }
Пример #2
0
        public async Task <UserServiceObject> CreatePatientAsync(UserServiceObject patientServiceObject, CancellationToken token)
        {
            await _createPatientValidationService.Validate(patientServiceObject, token);

            var patientEntity = _mapper.Map <UserEntity>(patientServiceObject);
            var createdEntity = await _patientRepository.CreatePatientAsync(patientEntity, token);

            return(_mapper.Map <UserServiceObject>(createdEntity));
        }
Пример #3
0
        public async Task CreatePatientAsync(PatientDTO doctorDTO)
        {
            if (doctorDTO == null)
            {
                throw new ArgumentNullException(nameof(doctorDTO));
            }

            var doctor = _mapper.Map <Patient>(doctorDTO);

            await _patientRepository.CreatePatientAsync(doctor);

            await _patientRepository.SaveAsync();
        }
Пример #4
0
 public async Task <IActionResult> CreatePatients([FromBody] Patient patient)
 {
     return(Ok(await _context.CreatePatientAsync(patient)));
 }