Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("OrderId,OrderDate,UserId,Total,FirstName,LastName,Address,City,Province,PostalCode,Phone")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(order));
        }
        public async Task <IActionResult> Create([Bind("CategoryId,Name")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,NormalizedName,ConcurrencyStamp")] ApplicationRole applicationRole)
        {
            if (ModelState.IsValid)
            {
                _context.Add(applicationRole);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(applicationRole));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("ProductId,Name,Description,Price,Photo,CategoryId")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Category, "CategoryId", "Name", product.CategoryId);
            return(View(product));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("CartId,ProductId,Quantity,Price,Username")] Cart cart)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cart);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "Name", cart.ProductId);
            return(View(cart));
        }
        public async Task <IActionResult> Create([Bind("OrderDetailId,OrderId,ProductId,Quantity,Price")] OrderDetail orderDetail)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orderDetail);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"]   = new SelectList(_context.Order, "OrderId", "Address", orderDetail.OrderId);
            ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "Name", orderDetail.ProductId);
            return(View(orderDetail));
        }