Esempio n. 1
0
        /// <summary>
        /// Save a new CnsExploration to the database with the data from a viewmodel.
        /// </summary>
        /// <param name="viewModel">Viewmodel with the new exploration data.</param>
        /// <returns>Id of the newly created CnsExploration.</returns>
        public int Create(CnsExplorationViewModel viewModel)
        {
            //Create a new CnsExploration from the viewmodel
            var cnsExploration = viewModel.ToNewModel();

            Repository.CnsExplorations.Add(cnsExploration);
            Save();

            return(cnsExploration.Id);
        }
Esempio n. 2
0
        public void Update_NotFound()
        {
            //Arrange
            var explorationViewModel = new CnsExplorationViewModel
            {
                Id = 123456
            };

            //Act
            _cnsExplorationService.Update(explorationViewModel);
        }
Esempio n. 3
0
        /// <summary>
        /// Update the CnsExploration with the data from the given viewmodel.
        /// </summary>
        /// <param name="viewModel">Viewmodel with the modified data.</param>
        public void Update(CnsExplorationViewModel viewModel)
        {
            var cnsExploration = Repository.CnsExplorations.SingleOrDefault(e => e.Id == viewModel.Id);

            if (cnsExploration == null)
            {
                return;
            }

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

            Save();
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        public void Create()
        {
            //Arrange
            var cnsExplorationViewModel = new CnsExplorationViewModel
            {
                Behavior      = Behavior.Irregular,
                CranialNerves = CranialNerves.Irregular,
                Tone          = Tone.Low,
                Position      = Position.Irregular,
                Reflexes      = Reflexes.Normal
            };

            //Act
            var explorationId = _cnsExplorationService.Create(cnsExplorationViewModel);
            var exploration   = _dataContext.CnsExplorations.SingleOrDefault(e => e.Id == explorationId);

            //Assert
            Assert.That(explorationId, Is.Not.Zero);
            Assert.That(exploration, Is.Not.Null);
        }