public void Update() { //Arrange var exploration = _dataContext.CnsExplorations.First(); var explorationViewModel = new CnsExplorationViewModel(exploration) { Position = Position.Irregular }; //Act _cnsExplorationService.Update(explorationViewModel); exploration = _dataContext.CnsExplorations.FirstOrDefault(e => e.Id == explorationViewModel.Id); //Assert Assert.That(exploration, Is.Not.Null); Assert.That(exploration.Position, Is.EqualTo(explorationViewModel.Position)); }
/// <summary> /// Update the Hypothermia 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(EditHypothermiaViewModel viewModel) { var hypothermia = Repository.Hypothermias.SingleOrDefault(e => e.Id == viewModel.Id); if (hypothermia == null) { return(false); } //Update the hypothermia with the viewmodel data viewModel.ToModel(hypothermia); Repository.Entry(hypothermia).State = EntityState.Modified; //Update associated CnsExploration _cnsExplorationService.Update(viewModel.CnsExploration); //Update associated Analysis _analysisService.Update(viewModel.Analysis); Save(); return(true); }
/// <summary> /// Update the NbrSurveillance 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(EditNbrSurveillanceViewModel viewModel) { var nbrSurveillance = Repository.NbrSurveillances .SingleOrDefault(n => n.Id == viewModel.Id); if (nbrSurveillance == null) { return(false); } //Update the surveillance with the viewmodel data viewModel.ToModel(nbrSurveillance); Repository.Entry(nbrSurveillance).State = EntityState.Modified; //Update associated CnsExploration _cnsExplorationService.Update(viewModel.CnsExploration); //Update associated Analysis _analysisService.Update(viewModel.Analysis); Save(); return(true); }