Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using Dream.Models;
  6. namespace Dream.Areas.Admin.Models
  7. {
  8. public class ProductModel
  9. {
  10. public List<Category> categoryList {get; set;}
  11. public List<Item> products { get; set; }
  12. }
  13. }
  14.  
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Linq;
  18. using System.Web;
  19. using System.Web.Mvc;
  20. using Dream.Models;
  21. using Dream.Areas.Admin.Models;
  22.  
  23. namespace Dream.Areas.Admin.Controllers
  24. {
  25. public class ProductController : Controller
  26. {
  27. //
  28. // GET: /Admin/Product/
  29. MightyMouseContainer ctx = new MightyMouseContainer();
  30. ProductModel product = new ProductModel();
  31.  
  32. public ActionResult Index()
  33. {
  34.  
  35. product.categoryList = ctx.Categories.ToList();
  36.  
  37. var cat = product.categoryList.Select(c => new { c.Category_ID, c.Category_Description});
  38. ViewBag.Categories = new SelectList(cat.AsEnumerable(), "Category_ID", "Category_Description");
  39.  
  40. return View(product);
  41. }
  42.  
  43. //
  44. // GET: /Admin/Product/Details/5
  45.  
  46. public ActionResult Details(int id)
  47. {
  48. return View();
  49. }
  50.  
  51. //
  52. // GET: /Admin/Product/Create
  53.  
  54. public ActionResult Create()
  55. {
  56. return View();
  57. }
  58.  
  59. //
  60. // POST: /Admin/Product/Create
  61.  
  62. [HttpPost]
  63. public ActionResult Create(FormCollection collection)
  64. {
  65. try
  66. {
  67. // TODO: Add insert logic here
  68.  
  69. return RedirectToAction("Index");
  70. }
  71. catch
  72. {
  73. return View();
  74. }
  75. }
  76.  
  77. //
  78. // GET: /Admin/Product/Edit/5
  79.  
  80. public ActionResult Edit(int id)
  81. {
  82. return View();
  83. }
  84.  
  85. //
  86. // POST: /Admin/Product/Edit/5
  87.  
  88. [HttpPost]
  89. public ActionResult Edit(int id, FormCollection collection)
  90. {
  91. try
  92. {
  93. // TODO: Add update logic here
  94.  
  95. return RedirectToAction("Index");
  96. }
  97. catch
  98. {
  99. return View();
  100. }
  101. }
  102.  
  103. //
  104. // GET: /Admin/Product/Delete/5
  105.  
  106. public ActionResult Delete(int id)
  107. {
  108. return View();
  109. }
  110.  
  111. //
  112. // POST: /Admin/Product/Delete/5
  113.  
  114. [HttpPost]
  115. public ActionResult Delete(int id, FormCollection collection)
  116. {
  117. try
  118. {
  119. // TODO: Add delete logic here
  120.  
  121. return RedirectToAction("Index");
  122. }
  123. catch
  124. {
  125. return View();
  126. }
  127. }
  128. }
  129. }
  130.  
  131. <%:Html.EditorFor(p => p.products.Category_ID %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement