public async Task <IActionResult> Edit(int id, [Bind("CustomerId,CustomerName,CustomerPhone,CustomerEmail,Password")] Customers customers) { if (id != customers.CustomerId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(customers); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomersExists(customers.CustomerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(customers)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,CustomerId,ProductId")] Cart cart) { if (id != cart.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cart); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CartExists(cart.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "Password", cart.CustomerId); ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "CostUnit", cart.ProductId); return(View(cart)); }
public async Task <IActionResult> Edit([Bind("DepartmentName")] Departments departments) { if (ModelState.IsValid) { try { _context.Update(departments); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartmentsExists(departments.DepartmentName)) { return(NotFound()); } else { throw; } } @TempData["Message"] = "Category " + departments.DepartmentName + " updated Succesfully!"; return(RedirectToAction("ProductCategories", "Admins")); } return(View(departments)); }
public async Task <IActionResult> Edit(int id, [Bind("ProductId,ProductName,PricePerCostUnit,CostUnit,DepartmentName,QuantityInStock,Brand,ProductionDate,BestBeforeDate,Plu,Upc,Organic,Cut,Animal")] Products products) { if (id != products.ProductId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(products); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductsExists(products.ProductId)) { return(NotFound()); } else { throw; } } TempData["Message"] = products.ProductName + " has been edited succesfully!"; return(RedirectToAction("Products", "Admins")); } ViewData["DepartmentName"] = new SelectList(_context.Departments, "DepartmentName", "DepartmentName", products.DepartmentName); return(View(products)); }
public async Task <IActionResult> Edit(int id, [Bind("TransactionId,ProductId,Quantity,CustomerId,PurchaseDate,Total")] Purchases purchases) { if (id != purchases.TransactionId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(purchases); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PurchasesExists(purchases.TransactionId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "Password", purchases.CustomerId); ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "CostUnit", purchases.ProductId); return(View(purchases)); }
public async Task <IActionResult> Edit(int id, [Bind("PaymentId,CartId,CustomerId,NameOnCard,CardNumber,Expiration,Cvv")] Payment payment) { if (id != payment.PaymentId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(payment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PaymentExists(payment.PaymentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CartId"] = new SelectList(_context.Cart, "Id", "Id", payment.CartId); ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "Password", payment.CustomerId); return(View(payment)); }
public async Task <IActionResult> Edit(int id, [Bind("AdminId,Name,Password")] Admin admin) { if (id != admin.AdminId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(admin); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdminExists(admin.AdminId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(admin)); }
public async Task <IActionResult> Edit([Bind("DepartmentName")] Departments departments) { if (departments.DepartmentName == null) { return(NotFound()); } if (ModelState.IsValid) { _context.Update(departments); await _context.SaveChangesAsync(); @TempData["Message"] = "Category " + departments.DepartmentName + " updated Succesfully!"; return(RedirectToAction("ProductCategories", "Admins")); } return(View(departments)); }