Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        public bool Remove(string id)
        {
            var retVal = _repository.Remove(id);

            if (retVal && SelectedElement != null && SelectedElement.Id == id)
            {
                SelectedElement = null;
            }

            return(retVal);
        }
        public IActionResult DeleteElementById(int id)
        {
            if (_repo.GetElementById(id) == null)
            {
                return(NotFound("This element does not exist in the database"));
            }

            _repo.Remove(id);

            return(Ok());
        }
Ejemplo n.º 3
0
        public void Remove_ByItem_RemovesItem()
        {
            var person = new Mock <ProjectElement>();

            person.Setup(p => p.Id).Returns("joe");
            person.Setup(p => p.FolderPath).Returns("*mocked*");
            using (var tempFolder = new TemporaryFolder("ElementRepoTestFolder"))
            {
                var repo = new ElementRepository <ProjectElement>(tempFolder.Path,
                                                                  "elementGroupName", null, (folder, id, idChangedAction) => person.Object);

                repo.CreateNew("joe");
                Assert.IsTrue(repo.AllItems.Contains(person.Object));
                repo.Remove(person.Object);
                Assert.IsFalse(repo.AllItems.Contains(person.Object));
            }
        }