Exemple #1
0
        public void FindByPatientId()
        {
            //Arrange
            var patientId = _dataContext.Hypothermias.First().PatientId;

            //Act
            var hypothermias = _hypothermiaService.FindByPatientId(patientId);

            //Assert
            Assert.That(hypothermias, Is.Not.Empty);
        }
Exemple #2
0
        /// <summary>
        /// Delete the patient with the given id.
        /// </summary>
        /// <param name="id">Id of the patient to delete.</param>
        /// <returns>bool indicating if the deletion was successful.</returns>
        public bool Delete(int id)
        {
            var exists = Repository.Patients.Any(p => p.Id == id);

            if (!exists)
            {
                return(false);
            }

            //Delete related NbrSurveillances
            var surveillances = _nbrSurveillanceService.FindByPatientId(id);

            surveillances.ForEach(s => _nbrSurveillanceService.Delete(s.Id));

            //Delete related Hypothermias
            var hypothermias = _hypothermiaService.FindByPatientId(id);

            hypothermias.ForEach(h => _hypothermiaService.Delete(h.Id));

            //Load related entities and delete patient
            var patient = new Patient {
                Id = id
            };

            Repository.Patients.Attach(patient);

            Repository.Entry(patient).Collection(p => p.Operations).Load();
            Repository.Patients.Remove(patient);

            Save();
            return(true);
        }
Exemple #3
0
        public void Delete_WithHypothermia()
        {
            //Arrange
            var patientId = _dataContext.Patients.AsNoTracking().First(p => p.PatientStatus == PatientStatus.Hypothermia).Id;

            //Act
            var deleted      = _patientService.Delete(patientId);
            var patient      = _patientService.FindById(patientId);
            var hypothermias = _hypothermiaService.FindByPatientId(patientId);

            //Assert
            Assert.That(deleted, Is.True);
            Assert.That(patient, Is.Null);
            Assert.That(hypothermias, Is.Empty);
        }
Exemple #4
0
        // GET: Hypothermia/View/5
        public ActionResult View(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var patientId    = (int)id;
            var hypothermias = _hypothermiaService.FindByPatientId(patientId);

            var viewModel = new ViewHypothermiaViewModel
            {
                PatientId    = (int)id,
                Hypothermias = hypothermias
            };

            return(View(viewModel));
        }