コード例 #1
0
        public async Task Store(TreeService treeService)
        {
            System.Diagnostics.Debug.WriteLine("Family {0}", this.family.Id);
            await treeService.Update(this.family).ConfigureAwait(false);

            await treeService.UpdateRelations(this.family.Id, this.spouses, this.children).ConfigureAwait(false);
        }
コード例 #2
0
        public IActionResult Update(string id, Tree treeIn)
        {
            var tree = _treeService.Get(id);

            if (tree == null)
            {
                return(NotFound());
            }

            _treeService.Update(id, treeIn);

            return(NoContent());
        }
コード例 #3
0
        public ActionResult Edit(Tree model)
        {
            if (ModelState.IsValid)
            {
                var user = GetUser();
                model.UserID = user.ID;
                TreeService.Update(model);

                var path  = Server.MapPath("/label");
                var bytes = TreeTagPainter.Paint(model, HttpContext.Request.Url.Host);
                System.IO.File.WriteAllBytes(path + "/" + model.ID + ".png", bytes);

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(model));
            }
        }
コード例 #4
0
 public async Task Store(TreeService treeService)
 {
     System.Diagnostics.Debug.WriteLine("Individual {0}, {1} {2}", this.individual.Id, this.individual.Firstnames, this.individual.Lastname);
     await treeService.Update(this.individual).ConfigureAwait(false);
 }
コード例 #5
0
 public void Update(int id, Tree tree)
 {
     _service.Update(id, tree);
 }
コード例 #6
0
        public void TreeService_Update_Calls_UnitOfWork_Commit_Method_()
        {
            // Create test data
            var tree = new Tree
                            {
                                Name = "Foo"
                            };

            //Create Mock
            var mockRepository = new Mock<IRepository<Tree>>();
            _mockUnitOfWork.Setup(d => d.GetRepository<Tree>()).Returns(mockRepository.Object);

            //Arrange
            _service = new TreeService(_mockUnitOfWork.Object);

            //Act
            _service.Update(tree);

            //Assert
            _mockUnitOfWork.Verify(db => db.Commit());
        }
コード例 #7
0
        public void TreeService_Update_Calls_Repository_Update_Method_With_The_Same_Tree_Object_It_Recieved()
        {
            // Create test data
            var tree = new Tree
                            {
                                Name = "Foo"
                            };

            //Create Mock
            var mockRepository = new Mock<IRepository<Tree>>();
            _mockUnitOfWork.Setup(d => d.GetRepository<Tree>()).Returns(mockRepository.Object);

            //Arrange
            _service = new TreeService(_mockUnitOfWork.Object);

            //Act
            _service.Update(tree);

            //Assert
            mockRepository.Verify(r => r.Update(tree));
        }