Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using Dream.Models;
- namespace Dream.Areas.Admin.Models
- {
- public class ProductModel
- {
- public List<Category> categoryList {get; set;}
- public List<Item> products { get; set; }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Dream.Models;
- using Dream.Areas.Admin.Models;
- namespace Dream.Areas.Admin.Controllers
- {
- public class ProductController : Controller
- {
- //
- // GET: /Admin/Product/
- MightyMouseContainer ctx = new MightyMouseContainer();
- ProductModel product = new ProductModel();
- public ActionResult Index()
- {
- product.categoryList = ctx.Categories.ToList();
- var cat = product.categoryList.Select(c => new { c.Category_ID, c.Category_Description});
- ViewBag.Categories = new SelectList(cat.AsEnumerable(), "Category_ID", "Category_Description");
- return View(product);
- }
- //
- // GET: /Admin/Product/Details/5
- public ActionResult Details(int id)
- {
- return View();
- }
- //
- // GET: /Admin/Product/Create
- public ActionResult Create()
- {
- return View();
- }
- //
- // POST: /Admin/Product/Create
- [HttpPost]
- public ActionResult Create(FormCollection collection)
- {
- try
- {
- // TODO: Add insert logic here
- return RedirectToAction("Index");
- }
- catch
- {
- return View();
- }
- }
- //
- // GET: /Admin/Product/Edit/5
- public ActionResult Edit(int id)
- {
- return View();
- }
- //
- // POST: /Admin/Product/Edit/5
- [HttpPost]
- public ActionResult Edit(int id, FormCollection collection)
- {
- try
- {
- // TODO: Add update logic here
- return RedirectToAction("Index");
- }
- catch
- {
- return View();
- }
- }
- //
- // GET: /Admin/Product/Delete/5
- public ActionResult Delete(int id)
- {
- return View();
- }
- //
- // POST: /Admin/Product/Delete/5
- [HttpPost]
- public ActionResult Delete(int id, FormCollection collection)
- {
- try
- {
- // TODO: Add delete logic here
- return RedirectToAction("Index");
- }
- catch
- {
- return View();
- }
- }
- }
- }
- <%:Html.EditorFor(p => p.products.Category_ID %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement