public async Task <IActionResult> Edit(int id, [Bind("ProdId,SizeId,ColorId,Quantity")] ProductsQuantity productsQuantity) { if (id != productsQuantity.ProdId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(productsQuantity); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductsQuantityExists(productsQuantity.ProdId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProdId"] = new SelectList(_context.Product, "Id", "Id", productsQuantity.ProdId); ViewData["ColorId"] = new SelectList(_context.ProductColor, "Id", "Id", productsQuantity.ColorId); ViewData["SizeId"] = new SelectList(_context.ProductSize, "Id", "Id", productsQuantity.SizeId); return(View(productsQuantity)); }
public async Task <IActionResult> ViewDetails([Bind("ProdId,SizeId,ColorId,Quantity")] ProductsQuantity productsQuantity) { if (ModelState.IsValid) { _context.Add(productsQuantity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProdId"] = new SelectList(_context.Product, "Id", "Id", productsQuantity.ProdId); ViewData["ColorId"] = new SelectList(_context.ProductColor, "Id", "Id", productsQuantity.ColorId); ViewData["SizeId"] = new SelectList(_context.ProductSize, "Id", "Id", productsQuantity.SizeId); return(View(productsQuantity)); }