public Product Add(Product product) { context.Add(product); //Need this to save to the actual database, and not just the injected context database context.SaveChanges(); return(product); }
public async Task <IActionResult> Create([Bind("ShoppingListLineID,ListID,ProductID,ProductName,Quantity")] ShoppingListLine shoppingListLine) { if (ModelState.IsValid) { _context.Add(shoppingListLine); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(shoppingListLine)); }
public async Task <IActionResult> Create([Bind("StoreID,StoreName,Street,City,State,ZipCode")] Store store) { if (ModelState.IsValid) { _context.Add(store); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(store)); }
public async Task <IActionResult> Create([Bind("ProductID,ProductName,CategoryID")] Product product) { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Create([Bind("AisleID,StoreID,AisleNumber,CategoryID")] Aisle aisle) { if (ModelState.IsValid) { _context.Add(aisle); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(aisle)); }
public async Task <IActionResult> Create([Bind("CategoryID,CategoryName")] Category category) { if (ModelState.IsValid) { _context.Add(category); await _context.SaveChangesAsync(); 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)); }