// GET: MasterPartLists/Create public ActionResult Create() { ViewBag.ReturnUrl = Request.UrlReferrer; var customers = db.Customers.ToList(); var customerdivisions = db.CustomerDivisions.ToList(); var mlsdivisions = db.MlsDivisions.ToList(); var parttypes = db.PartTypes.ToList(); var activeparts = db.ActiveParts.ToList(); var viewModel = new SaveMasterViewModel() { Customers = customers, CustomerDivisions = customerdivisions, MlsDivisions = mlsdivisions, PartTypes = parttypes, ActiveParts = activeparts }; return(View("Create", viewModel)); //return View(); }
// GET: MasterPartLists/Edit/5 public ActionResult Edit(int?id) { ViewBag.ReturnUrl = Request.UrlReferrer; var masterpartlists = db.MasterPartLists.SingleOrDefault(c => c.PartId == id); var customers = db.Customers.ToList(); var customerdivisions = db.CustomerDivisions.ToList(); var mlsdivisions = db.MlsDivisions.ToList(); var parttypes = db.PartTypes.ToList(); var activeparts = db.ActiveParts.ToList(); var viewModel = new SaveMasterViewModel() { MasterPartList = masterpartlists, Customers = customers, CustomerDivisions = customerdivisions, MlsDivisions = mlsdivisions, PartTypes = parttypes, ActiveParts = activeparts }; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //Support support = db.Supports.Include(s => s.FileDetails).SingleOrDefault(x => x.SupportId == id); //MasterPartList masterPartList = db.MasterPartLists.Include(s => s.FileDetails).SingleOrDefault(x => x.PartId == id); MasterPartList masterPartList = db.MasterPartLists.Find(id); if (masterPartList == null) { return(HttpNotFound()); } return(View("Edit", viewModel)); //return View(masterPartList); }