public ActionResult Create(ProdsUsedInSubCat psc, string PostMethod) { try { if (ModelState.IsValid) { var viewModel = new ProductsSubCatsViewModel { Psc = psc, Products = _context.Products.ToList(), SubCat = _context.subCategories.ToList() }; } psc.ApplicationUserCreatedById = "4af95f1c-0f73-4df9-bb6d-166a07b6e5f4"; psc.ApplicationUserCreatedDate = DateTime.Now; psc.ApplicationUserLastUpdatedById = psc.ApplicationUserCreatedById; psc.ApplicationUserLastUpdatedDate = DateTime.Now; // TODO: Add insert logic here _context.prodsUsedInSubCats.Add(psc); _context.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, ProdsUsedInSubCat psc) { try { if (!ModelState.IsValid) { var viewModel = new ProductsSubCatsViewModel { Psc = psc, Products = _context.Products.ToList(), SubCat = _context.subCategories.ToList() }; //return View("CustomerForm", viewModel); } // TODO: Add update logic here var pscinDb = _context.prodsUsedInSubCats.Single(s => s.Id == psc.Id); pscinDb.SubCatId = psc.SubCatId; pscinDb.ProductId = psc.ProductId; pscinDb.QtyUsed = psc.QtyUsed; _context.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { return(View("Index")); } }
// GET: VenueServices/Create public ActionResult Create(ProdsUsedInSubCat psc) { try { var viewModel = new ProductsSubCatsViewModel { Psc = psc, Products = _context.Products.ToList(), SubCat = _context.subCategories.ToList() }; return(View("Create", viewModel)); } catch (Exception ex) { return(View()); } }
// GET: VenueServices/Edit/5 public ActionResult Edit(int id) { var psc = _context.prodsUsedInSubCats.SingleOrDefault(c => c.Id == id); if (psc == null) { return(HttpNotFound()); } var viewModel = new ProductsSubCatsViewModel { Psc = psc, Products = _context.Products.ToList(), SubCat = _context.subCategories.ToList() }; return(View(viewModel)); }