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));
        }
Beispiel #2
0
        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));
        }
        public async Task <IActionResult> RemoveShoppingList(int id)
        {
            var shoppingListLine = await _context.ShoppingListLine.FindAsync(id);

            _context.ShoppingListLine.Remove(shoppingListLine);
            await _context.SaveChangesAsync();

            var user = await _userManager.FindByNameAsync(User.Identity.Name);

            return(RedirectToAction("ShoppingList", "ShoppingListLines", new { userName = user.Email }));
        }