using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using OrderApplicationXML.Data_Access_Layer; using OrderApplicationXML.Models; namespace OrderApplicationXML.Controllers { public class OrderController : Controller { // GET: Order public ActionResult Index() { var orders = OrderXmlDataAccess.GetAllOrders(); return View(orders); } // GET:/Create. public ActionResult Create() { return View(); } //POST:Create. [HttpPost] public ActionResult Create(SalesOrder order) { if(ModelState.IsValid) { OrderXmlDataAccess.AddOrder(order); return RedirectToAction("Index"); } return View(order); } // GET:/Details. public ActionResult Details(string id) { var order = OrderXmlDataAccess.GetOrderById(id); if(order == null) { return HttpNotFound(); } return View(order); } // POST: Edit. [HttpPost] public ActionResult Edit(SalesOrder order) { if(ModelState.IsValid) { OrderXmlDataAccess.UpdateOrder(order); return RedirectToAction("Index"); } return View(order); } // delete an order. public ActionResult Delete(string id) { var order = OrderXmlDataAccess.GetOrderById(id); if(order == null) { return HttpNotFound(); } return View(order); } [HttpPost, ActionName("Delete")] public ActionResult DeleteConfirmed(string id) { OrderXmlDataAccess.DeleteOrder(id); return View(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)