public async Task <ActionResult <Patient> > PostPersonAsDoctor(PersonAsDoctorRegistrationDTO person) { Person addedUser; using (var transaction = new TransactionScope()) { if (!(_peopleController.RegisterUser(person) is CreatedResult result)) { return(BadRequest(BadRequestEmptyJsonResult)); } addedUser = _peopleRepository.GetByEmail(person.Email); Doctor doctor = new Doctor() { Id = addedUser.Id, SpecialityId = person.SpecialityId }; if (!(PostDoctor(doctor) is CreatedResult resultDoctor)) { return(BadRequest(BadRequestEmptyJsonResult)); } transaction.Complete(); } addedUser.Doctor = await _repository.GetByIdWithSpecialization(addedUser.Id); return(Created("", addedUser)); }
public async Task <ActionResult <Patient> > PostPersonAsPatient(PersonRegistrationDTO person) { using (var transaction = new TransactionScope()) { if (!(_peopleController.RegisterUser(person) is CreatedResult result)) { return(BadRequest(BadRequestEmptyJsonResult)); } Person user = _peopleRepository.GetByEmail(person.Email); Patient newPatient = new Patient() { Id = user.Id, IdNavigation = user }; if (!(await PostPatient(newPatient) is CreatedResult resultDoctor)) { return(BadRequest(BadRequestEmptyJsonResult)); } //_repository.Insert(newPatient); //_repository.Save(); transaction.Complete(); user.Patient = newPatient; return(Created("", user)); } }