public async Task <IActionResult> Update(int id, [FromBody] Product product)
        {
            if (id != product.IdProduct)
            {
                return(BadRequest());
            }

            try
            {
                _context.Update(product);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(Content("Product updated successfull"));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("IdProduct,ProductCode,ProductType,Description,UnitPrice,QtyInStock")] Product product)
        {
            if (id != product.IdProduct)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.IdProduct))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Beispiel #3
0
        public async Task <IActionResult> Edit(int id, [Bind("playerId,playerName,playerNumber,teamName")] Player player)
        {
            if (id != player.playerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(player);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlayerExists(player.playerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(player));
        }