Exemplo n.º 1
0
        public ActionResult Create(PageInputModel inputModel)
        {
            if (ModelState.IsValid)
            {
                var page = new Page();
                Mapper.Map(inputModel, page);

                page.CreatedOn = DateTime.Now;
                page = Pages.Add(page);

                return RedirectToAction("Details", new { id = page.Id });
            }

            return View(inputModel);
        }
Exemplo n.º 2
0
        public ActionResult Edit(string id, PageInputModel inputModel)
        {
            var page = Pages.GetById(id);
            if (page == null)
                return HttpNotFound("no such page");

            if (ModelState.IsValid)
            {
                Mapper.Map(inputModel, page);
                page.UpdatedOn = DateTime.Now;
                Pages.Update(page);

                this.FlashInfo("Updated page.");

                return RedirectToAction("Display", new { controller = "Page", area = string.Empty, slug = page.Slug });
            }

            return View(inputModel);
        }