// GET: Styles/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(RedirectToAction("Index", "Home")); } StyleViewModel svm = new StyleViewModel(); svm.Style = db.Styles.Find(id); if (svm.Style == null) { return(HttpNotFound()); } svm.Style.JewelryType = db.JewelryTypes.Find(svm.Style.JewelryTypeId); Collection co = db.Collections.Find(svm.Style.CollectionId); svm.CompanyId = co.CompanyId; svm.Style.MetalWeightUnit = new MetalWeightUnit { Unit = "DWT" }; svm.Populate(id, db); string markup = db.FindCompany(svm.CompanyId).markup; if (markup == null) { markup = "[]"; } svm.markups = JsonConvert.DeserializeObject <List <Markup> >(markup); ViewBag.CollectionId = new SelectList(db.Collections.Where(x => x.CompanyId == co.CompanyId), "Id", "Name", svm.Style.CollectionId); //ViewBag.JewelryTypeId = new SelectList(db.JewelryTypes.Where(x => x.CompanyId == co.CompanyId), "Id", "Name", svm.Style.JewelryTypeId); ViewBag.MetalWtUnitId = new SelectList(db.MetalWeightUnits.OrderBy(mwu => mwu.Unit), "Id", "Unit", svm.Style.MetalWtUnitId); return(View(svm)); }
// GET: Styles/Create public ActionResult Create(int collectionId) { Collection co = db.Collections.Find(collectionId); StyleViewModel svm = new StyleViewModel(); svm.CompanyId = co.CompanyId; svm.SVMOp = SVMOperation.Create; svm.Populate(null, db); AddDefaultEntries(svm); return(CreateNew(svm.CompanyId, collectionId, svm)); }
// GET: Styles/Details/5 public ActionResult Details(int?id) { StyleViewModel svm = new StyleViewModel(); if (id == null) { return(RedirectToAction("Index", "Home")); } svm.Style = db.Styles.Find(id); if (svm.Style == null) { return(HttpNotFound()); } svm.Populate(id, db); return(View(svm)); }
public ActionResult Print(int?id) { StyleViewModel sm = new StyleViewModel(); if (id == null) { return(RedirectToAction("Index", "Home")); } sm.Style = db.Styles.Find(id); if (sm.Style == null) { return(HttpNotFound()); } sm.Style.Collection = db.Collections.Find(sm.Style.CollectionId); sm.Style.JewelryType = db.JewelryTypes.Find(sm.Style.JewelryTypeId); sm.CompanyId = sm.Style.Collection.CompanyId; sm.Populate(id, db); sm.SVMOp = SVMOperation.Print; return(View(sm)); }