Esempio n. 1
0
 public async Task <IActionResult> Create([Bind("ProductId,ProductName,Category,UnitPrice,UnitsInStock")] Product product, IFormFile file)
 {
     if (ModelState.IsValid)
     {
         _context.Add(product);
         await _context.SaveChangesAsync();
     }
     return(RedirectToAction("Index", "Products"));
 }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("IdProduct,ProductCode,ProductType,Description,UnitPrice,QtyInStock")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("playerId,playerName,playerNumber,teamName")] Player player)
        {
            if (ModelState.IsValid)
            {
                _context.Add(player);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(player));
        }
Esempio n. 4
0
        public async Task <IActionResult> Add(Product product)
        {
            try
            {
                var productTemp = _context.Products.Add(product);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(BadRequest());
            }

            return(StatusCode(200));
        }