public async Task <IActionResult> Edit(int id, [Bind("Id,ClientId,ProductId,Amount,DateOrder,IsInCart")] ShoppingCarts shoppingCarts) { if (id != shoppingCarts.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(shoppingCarts); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShoppingCartsExists(shoppingCarts.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ClientId"] = new SelectList(_context.Clients, "Id", "ClientName", shoppingCarts.ClientId); ViewData["ProductId"] = new SelectList(_context.Product, "Id", "ProductName", shoppingCarts.ProductId); return(View(shoppingCarts)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ClientName,UserId")] Clients clients) { if (id != clients.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(clients); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClientsExists(clients.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(clients)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ProductName,CategoryId,Price,Description,Photo")] Product product) { if (id != product.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "CategoryName", product.CategoryId); return(View(product)); }