Exemple #1
0
        public ActionResult Edit(WikiPageViewModel viewModel)
        {
            var page = new WikiPage()
            {
                Body = viewModel.Body,
                Title = viewModel.Title,
            };

            this._pageService.Save(page);

            return RedirectToAction("Index", new {id = page.Title});
        }
Exemple #2
0
        public ActionResult Edit(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
                throw new ArgumentOutOfRangeException("Page title is required.");

            var wikiPage = this._pageService.Get(id);
            var model = new WikiPageViewModel()
            {
                Body = wikiPage.Body,
                Title = wikiPage.Title,
            };
            return View(model);
        }
        public void Edit_Post()
        {
            //Given
            var viewModel = new WikiPageViewModel()
            {
                Body = "Some body text",
                Title = "Some title",
            };

            // When
            var result = this.Subject.Edit(viewModel);

            // Then
            this.PageService.Received().Save(Arg.Is<WikiPage>(page => page.Body == viewModel.Body && page.Title == viewModel.Title));
            Assert.That(result, Is.InstanceOf<RedirectToRouteResult>());
            var redirect = (result as RedirectToRouteResult);
            Assert.That(redirect.RouteName, Is.EqualTo("Index"));
            Assert.That(redirect.RouteValues["id"], Is.EqualTo("Some title"));
        }
Exemple #4
0
        // GET: Wiki
        public ActionResult Index(string id)
        {
            if (!string.IsNullOrWhiteSpace(id))
            {
                var wikiPage = this._pageService.Get(id);
                var transform = _markdown.Transform(wikiPage.Body);
                var model = new WikiPageViewModel()
                {
                    Body = transform,
                    Title = wikiPage.Title,
                };
                return View(model);
            }

            var emptyModel = new WikiPageViewModel()
            {
                Title = id,
                PageId = Guid.Empty,
            };
            return View(emptyModel);
        }