Exemplo n.º 1
0
        public void Update()
        {
            //Arrange
            var hypothermia = _dataContext.Hypothermias
                              .Include(h => h.CnsExploration)
                              .Include(h => h.Analysis)
                              .First();

            var viewModel = new EditHypothermiaViewModel(hypothermia)
            {
                Id             = hypothermia.Id,
                Convulsion     = true,
                CnsExploration = { Reflexes = Reflexes.Irregular },
                Analysis       = { Cpk = 20 }
            };

            //Act
            var updated = _hypothermiaService.Update(viewModel);

            hypothermia = _hypothermiaService.FindById(viewModel.Id);

            //Assert
            Assert.That(updated, Is.True);
            Assert.That(hypothermia.Convulsion, Is.True);
            Assert.That(hypothermia.CnsExploration.Reflexes, Is.EqualTo(Reflexes.Irregular));
            Assert.That(hypothermia.Analysis.Cpk, Is.EqualTo(20));
        }
Exemplo n.º 2
0
        public ActionResult Edit(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));
            }

            var updated = _hypothermiaService.Update(hypothermiaViewModel);

            //Update failed because of a wrong id
            if (!updated)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            //Update successful, log operation and redirect to view hypothermias
            _hypothermiaService.Log(OperationType.HypothermiaUpdate, User.Identity.GetUserId <int>(),
                                    patientId: fromId, data: "HypothermiaID: " + hypothermiaViewModel.Id);
            return(RedirectToAction("View", "Hypothermia", new { id = fromId }));
        }