Example #1
0
        public async Task<IActionResult> Edit(Guid id)
        {
            var page = await _pageService.GetByIdAsync(id);
            var viewModel = new PageEditViewModel
            {
                Name = page.Name,
                Title = page.Title,
                Permalink = page.Permalink
            };

            return View(viewModel);
        }
Example #2
0
        public async Task<IActionResult> Edit(Guid id, PageEditViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var page = await _pageService.GetByIdAsync(id);
                if (page == null)
                {
                    return NotFound(id);
                }

                page.Name = viewModel.Name;
                page.Permalink = viewModel.Permalink;
                page.Title = viewModel.Title;

                await _pageService.UpdateAsync(page);
                return RedirectToAction(nameof(Index));
            }

            return View(viewModel);
        }