Created
June 3, 2013 15:47
-
-
Save Maarten88/5699105 to your computer and use it in GitHub Desktop.
Controller in the Admin Area for Content Management with markdown. For blog post at http://www.macaw.nl/tags/Cloud%20Auction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web.Mvc; | |
using Auction.Web.Controllers; | |
using Auction.Web.Domain.Commands; | |
using Auction.Web.Domain.Entities; | |
using Auction.Web.Domain.Queries; | |
using Auction.Web.Security; | |
using Auction.Web.Domain; | |
namespace Auction.Web.Areas.Admin.Controllers | |
{ | |
[RequireHttps(Order = 1)] | |
[Authorize(Roles = "Administrators", Order = 2)] | |
public class ContentPagesController : BaseController | |
{ | |
// | |
// GET: /Seller/ContentPage/ | |
public ViewResult Index() | |
{ | |
var items = Query(new GetAllContentPages()); | |
return View(items); | |
} | |
// | |
// GET: /Seller/ContentPage/Details/5 | |
public ViewResult Details(int id) | |
{ | |
ContentPage contentpage = Query(new SingleContentPageById(id)); | |
return View(contentpage); | |
} | |
// | |
// GET: /Seller/ContentPage/Create | |
public ActionResult Create() | |
{ | |
var contentPage = new ContentPage(); | |
contentPage.Modified = DateTime.UtcNow; | |
return View(contentPage); | |
} | |
// | |
// POST: /Seller/ContentPage/Create | |
[HttpPost] | |
[ValidateInput(false)] | |
public ActionResult Create(ContentPage contentpage) | |
{ | |
if (ModelState.IsValid) | |
{ | |
ExecuteCommand(new InsertContentPage(contentpage)); | |
return RedirectToAction("Index"); | |
} | |
return View(contentpage); | |
} | |
// | |
// GET: /Seller/ContentPage/Edit/5 | |
public ActionResult Edit(int id) | |
{ | |
ContentPage contentpage = Query(new SingleContentPageById(id)); | |
return View(contentpage); | |
} | |
// | |
// POST: /Seller/ContentPage/Edit/5 | |
[HttpPost] | |
[ValidateInput(false)] | |
public ActionResult Edit(ContentPage contentpage) | |
{ | |
if (ModelState.IsValid) | |
{ | |
ExecuteCommand(new UpdateContentPage(contentpage)); | |
return RedirectToAction("Index"); | |
} | |
return View(contentpage); | |
} | |
// | |
// GET: /Seller/ContentPage/Delete/5 | |
public ActionResult Delete(int id) | |
{ | |
ContentPage contentpage = Query(new SingleContentPageById(id)); | |
return View(contentpage); | |
} | |
// | |
// POST: /Seller/ContentPage/Delete/5 | |
[HttpPost, ActionName("Delete")] | |
public ActionResult DeleteConfirmed(int id) | |
{ | |
ExecuteCommand(new DeleteContentPage(id)); | |
return RedirectToAction("Index"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment