예제 #1
0
        /// <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);
        }
예제 #2
0
 /// <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);
 }
예제 #3
0
        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);
        }
예제 #4
0
        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);
            }
        }