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 }) }); }
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)); }
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(); }
public async Task <IActionResult> CreatePatients([FromBody] Patient patient) { return(Ok(await _context.CreatePatientAsync(patient))); }