Created
May 12, 2013 22:54
-
-
Save Maarten88/5565264 to your computer and use it in GitHub Desktop.
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.Areas.Seller.Models; | |
using Auction.Web.Domain; | |
using Auction.Web.Domain.Commands; | |
using Auction.Web.Domain.Models; | |
using Auction.Web.Domain.Queries; | |
using Auction.Web.Security; | |
namespace Auction.Web.Areas.Seller.Controllers | |
{ | |
[RequireHttps(Order = 1)] | |
[Authorize(Roles = "Seller", Order=2)] | |
public class AuctionsController : Auction.Web.Controllers.BaseController | |
{ | |
// | |
// GET: /Seller/Auction/ | |
public ActionResult Index() | |
{ | |
var auctions = Query(new GetAllAuctions()); | |
return View(auctions.ToList()); | |
} | |
// | |
// GET: /Seller/Auction/Details/5 | |
public ActionResult Details(int id = 0) | |
{ | |
var auction = Query(new GetSingleAuction(id)); | |
if (auction == null) | |
{ | |
return HttpNotFound(); | |
} | |
return View(auction); | |
} | |
// | |
// GET: /Seller/Auction/Create | |
public ActionResult Create() | |
{ | |
return View(new AuctionViewModel()); | |
} | |
// | |
// POST: /Seller/Auction/Create | |
[HttpPost] | |
public ActionResult Create(AuctionViewModel model) | |
{ | |
if (ModelState.IsValid) | |
{ | |
Domain.Models.Auction auction = new Domain.Models.Auction(model); | |
ExecuteCommand(new InsertNewAuction(auction)); | |
return RedirectToAction("Index"); | |
} | |
return View(model); | |
} | |
// | |
// GET: /Seller/Auction/Edit/5 | |
public ActionResult Edit(int id = 0) | |
{ | |
Domain.Models.Auction auction = Query(new GetSingleAuction(id)); | |
AuctionViewModel model = new AuctionViewModel(auction); | |
if (auction == null) | |
{ | |
return HttpNotFound(); | |
} | |
return View(model); | |
} | |
// | |
// POST: /Seller/Auction/Edit/5 | |
[HttpPost] | |
public ActionResult Edit(AuctionViewModel model) | |
{ | |
if (ModelState.IsValid) | |
{ | |
Domain.Models.Auction auction = new Domain.Models.Auction(model); | |
ExecuteCommand(new UpdateAuction(auction)); | |
return RedirectToAction("Index"); | |
} | |
return View(model); | |
} | |
// | |
// GET: /Seller/Auction/Delete/5 | |
public ActionResult Delete(int id = 0) | |
{ | |
Domain.Models.Auction auction = Query(new GetSingleAuction(id)); | |
if (auction == null) | |
{ | |
return HttpNotFound(); | |
} | |
return View(auction); | |
} | |
// | |
// POST: /Seller/Auction/Delete/5 | |
[HttpPost, ActionName("Delete")] | |
public ActionResult DeleteConfirmed(int id) | |
{ | |
ExecuteCommand(new DeleteAuction(id)); | |
return RedirectToAction("Index"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment