// GET: tb_goodssort/Edit/5 public ActionResult Edit(int?id) { Sidebar(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tb_goodssort model = db.tb_goodssort.Find(id); var models = new tb_goodssortview { ID = model.ID, SortName = model.SortName, Grade = model.Grade, ParentID = model.ParentID, SortIndex = model.SortIndex, }; models.ImagePath.Images = model.ImagePath?.Split(',') ?? new string[0]; ViewBag.ParentID = new SelectList(db.tb_goodssort.Where(s => s.Grade == 1 && s.ParentID != s.ID), "ID", "SortName", models.ParentID); ViewBag.Grade = new SelectList(db.GoodsSortGrade.OrderBy(s => s.Index), "ID", "Name", models.Grade); if (models == null) { return(HttpNotFound()); } return(View(models)); }
public ActionResult DeleteConfirmed(int id) { tb_goodssort tb_goodssort = db.tb_goodssort.Find(id); db.tb_goodssort.Remove(tb_goodssort); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: tb_goodssort/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tb_goodssort tb_goodssort = db.tb_goodssort.Find(id); if (tb_goodssort == null) { return(HttpNotFound()); } return(View(tb_goodssort)); }
public ActionResult Create(tb_goodssortview tb_goodssort) { if (ModelState.IsValid) { var model = new tb_goodssort { SortName = tb_goodssort.SortName, Grade = tb_goodssort.Grade, ImagePath = string.Join(",", tb_goodssort.ImagePath.Images), ParentID = tb_goodssort.Grade == 1 ? 0 : tb_goodssort.ParentID, SortIndex = tb_goodssort.SortIndex }; db.tb_goodssort.Add(model); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tb_goodssort)); }