コード例 #1
0
ファイル: HypothermiaTests.cs プロジェクト: Thraxs/NtTracker
        public void Create()
        {
            //Arrange
            var viewModel = new EditHypothermiaViewModel
            {
                TimeSlot       = TimeSlot.H72,
                CnsUs          = CnsUltrasound.Edema,
                AEeg           = AElectroencephalogram.Convulsion,
                Eeg            = Electroencephalogram.Slow,
                Convulsion     = false,
                Cr             = CerebralResonance.CorpusCallosumInjury,
                CnsExploration = new CnsExplorationViewModel(),
                Analysis       = new AnalysisViewModel(),
                ModelState     = new ModelStateDictionary()
            };
            var patientId = _dataContext.Patients.First().Id;

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

            //Assert
            Assert.That(viewModel.ModelState.IsValid, Is.True);
            Assert.That(hypothermias, Is.Not.Empty);
            Assert.That(hypothermias.First().TimeSlot, Is.EqualTo(TimeSlot.H72));
            Assert.That(hypothermias.First().CnsExploration, Is.Not.Null);
            Assert.That(hypothermias.First().Analysis, Is.Not.Null);
        }
コード例 #2
0
        public ActionResult Create(int fromId, EditHypothermiaViewModel hypothermiaViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(hypothermiaViewModel));
            }

            //Check that the tracking is not closed
            if (_patientService.IsClosed(fromId))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            hypothermiaViewModel.ModelState = ModelState;
            _hypothermiaService.Create(hypothermiaViewModel, fromId);

            //Check validation again for repeated time slots
            if (!ModelState.IsValid)
            {
                return(View(hypothermiaViewModel));
            }

            _hypothermiaService.Log(OperationType.HypothermiaCreate, User.Identity.GetUserId <int>(), fromId);
            return(RedirectToAction("View", "Hypothermia", new { id = fromId }));
        }