/// <summary> This method converts <paramref name="patientDto"/> to <c>PatientUser</c> using <c>PatientAdapter</c> and sends it to <c>PatientsRepository</c>. </summary> /// <returns>Returns successfully created patient; otherwise, return <c>null</c></returns> public PatientUser Create(PatientDto patientDto) { PatientUser patient = PatientsRepository.Add(PatientAdapter.PatientDtoToPatient(patientDto)); EmailVerificationService.SendVerificationMail(new MailAddress(patient.email), patient.id); return(patient); }
/// <summary> This method converts <paramref name="patientDto"/> to <c>PatientUser</c> using <c>PatientAdapter</c> and sends it to <c>PatientsRepository</c>. </summary> /// <returns>Returns successfully created patient; otherwise, return <c>null</c></returns> public PatientUser Create(PatientDto patientDto) { if (PatientsRepository.GetByEmail(patientDto.Email) == null) { PatientUser patient = PatientsRepository.Add(PatientAdapter.PatientDtoToPatient(patientDto)); EmailVerificationService.SendVerificationMail(new MailAddress(patient.Email), patient.Id); return(patient); } return(null); }
public void Add_patient() { PatientDto myPatient = CreatePatient(); Patient convertedPatient = PatientAdapter.PatientDtoToPatient(myPatient); HospitalApp.Controllers.PatientController controller = new HospitalApp.Controllers.PatientController(this.SetupRepository(myPatient, convertedPatient).Object); var actionResult = controller.Add(convertedPatient); ConvertToObject(actionResult).ShouldBeEquivalentTo(myPatient); }
public void Set_random_general_practitioner() { using (var context = new MyDbContext(_options)) { SetupDatabase(context); HospitalApp.Services.DoctorService doctorService = new HospitalApp.Services.DoctorService(context); HospitalApp.Services.PatientService service = new HospitalApp.Services.PatientService(context, doctorService); PatientDto patient = service.GetById(12); Patient k = PatientAdapter.PatientDtoToPatient(patient); service.GiveRandomGeneralPractitioner(k); Assert.NotNull(k.GeneralPractitionerId); } }