コード例 #1
0
        public async Task <IActionResult> Create([Bind("CategoryId,CategoryName,Description")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,ZipCode,PostalAddress,PaymentCard,Cvv")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(order));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("ShoppingCartItemId,Amount,ShoppingCartId")] ShoppingCartItem shoppingCartItem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(shoppingCartItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(shoppingCartItem));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("UserName,Age,Password")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("Name,RealAdress,Adress")] Store store)
        {
            if (ModelState.IsValid)
            {
                _context.Add(store);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(store));
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("DrinkId,Name,ShortDescription,LongDescription,Price,ImageUrl,ImageThumbnailUrl,IsPreferredDrink,InStock,CategoryId")] Drink drink)
        {
            if (ModelState.IsValid)
            {
                _context.Add(drink);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Category, "CategoryId", "CategoryId", drink.CategoryId);
            return(View(drink));
        }
コード例 #7
0
        public async Task <IActionResult> Create([Bind("OrderDetailId,DrinkId,OrderId,Amount,Price")] OrderDetail orderDetail)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orderDetail);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DrinkId"] = new SelectList(_context.Drink, "DrinkId", "DrinkId", orderDetail.DrinkId);
            ViewData["OrderId"] = new SelectList(_context.Order, "OrderId", "OrderId", orderDetail.OrderId);
            return(View(orderDetail));
        }
コード例 #8
0
        public async Task <IActionResult> Create([Bind("UserName,Age,Password,Role")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                UserRole = user.Role;
                UserName = user.UserName;
                await _context.SaveChangesAsync();

                HttpContext.Session.SetString("UserName", user.UserName);
                HttpContext.Session.SetString("UserRole", user.Role);
                return(RedirectToAction("ThePreferredDrinks", "Drinks"));
            }
            return(View(user));
        }