コード例 #1
0
ファイル: PatientModelFixure.cs プロジェクト: DF3203/Diploma
        public void ToModel_ViewModelEqualsPatient()
        {
            Patient testPatient = new Patient
            {
                PatientId   = 1,
                FirstName   = "Andrew",
                LastName    = "Moshko",
                MiddleName  = "Victor",
                Age         = "18",
                Weight      = "83",
                Height      = "195",
                Email       = "*****@*****.**",
                PhoneNumber = "+380995135682",
                HomeNumber  = "-",
                Sex         = "man",
                Condition   = "lazy student with diploma in front of his nose"
            };

            PatientViewModel patient = new PatientViewModel();

            patient.ToModel(testPatient);

            Assert.Equal(patient.PatientId, testPatient.PatientId);
            Assert.Equal(patient.FirstName, testPatient.FirstName);
            Assert.Equal(patient.LastName, testPatient.LastName);
            Assert.Equal(patient.MiddleName, testPatient.MiddleName);
            Assert.Equal(patient.Age, testPatient.Age);
            Assert.Equal(patient.Weight, testPatient.Weight);
            Assert.Equal(patient.Height, testPatient.Height);
            Assert.Equal(patient.PhoneNumber, testPatient.PhoneNumber);
            Assert.Equal(patient.HomeNumber, testPatient.HomeNumber);
            Assert.Equal(patient.Sex, testPatient.Sex);
            Assert.Equal(patient.Condition, testPatient.Condition);
            // Assert.Equal(patient.IsActive, testPatient.IsActive);
        }
コード例 #2
0
        // public async Task<PatientViewModel> AddPatientAsync(PatientViewModel patientViewModel)
        // {
        //    try
        //    {
        //        Patient patient = await this.UltraRepository.AddPatientAsync(patientViewModel.ToEntity());

        // patientViewModel.ToModel(patient);

        // return patientViewModel;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        // }

        public async Task <PatientViewModel> AddPatientAsync(PatientViewModel patientViewModel)
        {
            try
            {
                Patient patient = await this.repository.AddPatientAsync(patientViewModel.ToEntity());

                patientViewModel.ToModel(patient);

                return(patientViewModel);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public async Task <PatientViewModel> UpdatePatientAsync(PatientViewModel patientViewModel)
        {
            try
            {
                Patient patient = new Patient();
                Debug.WriteLine($"1\n");
                patient = await this.repository.UpdatePatientAsync(patientViewModel.ToEntity());

                Debug.WriteLine($"{patient.PatientId}\n{patient.Email}\n{patient.FirstName}\n{patient.Condition}\n ");

                patientViewModel.ToModel(patient);

                return(patientViewModel);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
ファイル: PatientService.cs プロジェクト: Thraxs/NtTracker
        /// <summary>
        /// Update the patient with the data from the given viewmodel.
        /// </summary>
        /// <param name="viewModel">Viewmodel with the modified data.</param>
        /// <returns>bool indicating if the update was successful.</returns>
        public bool Update(PatientViewModel viewModel)
        {
            var patient = Repository.Patients.SingleOrDefault(p => p.Id == viewModel.Id);

            if (patient == null)
            {
                return(false);
            }

            //Update the patient with the viewmodel data
            viewModel.ToModel(patient);
            Repository.Entry(patient).State = EntityState.Modified;

            Save();

            //Check if status needs to be updated
            UpdateStatus(viewModel.Id);

            return(true);
        }