public async Task <IActionResult> Edit(int id, [Bind("ShoppingListLineID,ListID,ProductID,Quantity")] ShoppingListLine shoppingListLine) { if (id != shoppingListLine.ShoppingListLineID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(shoppingListLine); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShoppingListLineExists(shoppingListLine.ShoppingListLineID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(shoppingListLine)); }
public async Task <IActionResult> Edit(int id, [Bind("StoreID,StoreName,Street,City,State,ZipCode")] Store store) { if (id != store.StoreID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(store); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StoreExists(store.StoreID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(store)); }
public async Task <IActionResult> Edit(int id, [Bind("ProductID,ProductName,CategoryID")] Product product) { if (id != product.ProductID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.ProductID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Edit(int id, [Bind("AisleID,StoreID,AisleNumber,CategoryID")] Aisle aisle) { if (id != aisle.AisleID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(aisle); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AisleExists(aisle.AisleID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(aisle)); }
public async Task <IActionResult> Edit(int id, [Bind("CategoryID,CategoryName")] Category category) { if (id != category.CategoryID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.CategoryID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Create([Bind("UserID,FirstName,LastName,Email,Password,ListID,ListName,StorePref")] User user) { if (ModelState.IsValid) { user.Password = Encrypt(user.Password); if (user.ListName == null) { user.ListName = user.FirstName + "'s List"; } _context.Add(user); await _context.SaveChangesAsync(); var newuser = await _context.User.FirstOrDefaultAsync(m => m.Email == user.Email).ConfigureAwait(false); newuser.ListID = newuser.UserID; _context.Update(newuser); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }