Ejemplo n.º 1
0
        public async Task <ActionResult <Order> > EditOrder(int id, [Bind("Id, UserId, OrderItems, Total")] Order order)
        {
            order.Id = id;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(order);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderExists(id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(order);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <Product> > EditProduct(int id, [Bind("Id,Title,Description,Price")] Product product)
        {
            product.Id = id;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(product);
        }