public void InstallFromSkippedFile()
        {
            var dataStoreManager = new TestFixtureDataStoreManager();

            var firstPage = Models.CreateDocumentationPage();

            _documentationPageRepository.Create(firstPage);

            // Generate content file.
            var contentFileName = Path.GetTempFileName();

            dataStoreManager.ExportContent(contentFileName);


            // Change content and recreate installation file.
            var deletedPage   = Models.CreateDocumentationPage();
            var recreatedPage = Models.CreateDocumentationPage();
            var lastPage      = Models.CreateDocumentationPage();

            _documentationPageRepository.Create(deletedPage);
            _documentationPageRepository.Create(recreatedPage);
            _documentationPageRepository.Create(lastPage);
            _documentationPageRepository.Delete(recreatedPage.Id);
            _documentationPageRepository.Create(recreatedPage);
            _documentationPageRepository.Delete(deletedPage.Id);

            // Regenerate content file.
            dataStoreManager.ExportContent(contentFileName);

            // Reset data store and exercise startup file.
            dataStoreManager.DeleteDataStore();
            dataStoreManager.CreateDataStore();
            dataStoreManager.ImportContent(contentFileName);

            // Validate model ids.
            var newFirstPage      = _documentationPageRepository.Read(firstPage.Id);
            var deletedPageResult = _documentationPageRepository.Read(deletedPage.Id);

            Assert.That(deletedPageResult, Is.Null, "The data layer should return null for non-existant pages.");

            var newRecreatedPage = _documentationPageRepository.Read(recreatedPage.Id);
            var newLastPage      = _documentationPageRepository.Read(lastPage.Id);

            Assert.That(newFirstPage, Is.Not.Null, "First page should still exist.");
            Assert.That(newFirstPage.Title, Is.EqualTo(firstPage.Title), "Old first page title should match new page with its id.");
            Assert.That(newRecreatedPage, Is.Not.Null, "Recreated page should still exist.");
            Assert.That(newRecreatedPage.Title, Is.EqualTo(recreatedPage.Title), "Old recreated page title should match new recreated page title.");
            Assert.That(newLastPage, Is.Not.Null, "Last page should still exist.");
            Assert.That(newLastPage.Title, Is.EqualTo(lastPage.Title), "Old last page title should match new last page title.");
        }
        public ResponseState Process(string data)
        {
            var pageId = int.Parse(data);

            _bulletRepository.DeleteByPageId(pageId);
            _userPageSettingsRepository.DeleteByPageId(pageId);

            // Get the page so we have the parent id.
            var page = _pageRepository.Read(pageId);

            // Get its siblings and remove the page from the collection.
            var siblings = _pageRepository.ReadByParentId(page.ParentPageId);

            page = siblings.Where(p => p.Id == pageId).First();
            siblings.Remove(page);

            // Insert deleted page's children in order at deleted page's location.
            var children = _pageRepository.ReadByParentId(pageId);

            for (int i = children.Count - 1; i >= 0; i--)
            {
                siblings.Insert(page.Order, children[i]);
            }

            // Update parent id and order on all of deleted page's children and siblings.
            for (int i = page.Order; i < siblings.Count; i++)
            {
                var sibling = siblings[i];
                sibling.ParentPageId = page.ParentPageId;
                sibling.Order        = i;
                _pageRepository.Update(sibling);
            }

            // Delete page after all children have been moved.
            _pageRepository.Delete(pageId);

            // Return generic success message.
            return(new ResponseState
            {
                ContentType = ContentTypes.Html,
            });
        }