public async Task <IActionResult> PutProduct(long id, Product product)
        {
            if (id != product.Id)
            {
                return(BadRequest());
            }

            _context.Entry(product).State = EntityState.Modified;

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

            return(NoContent());
        }
        public async Task <IActionResult> PutCustomer(long id, Customer customer)
        {
            if (id != customer.Id)
            {
                return(BadRequest());
            }

            _context.Entry(customer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutOrder(long id, Order order)
        {
            var originalOrder = _context.Orders
                                .Where(o => o.Id == id)
                                .Include(o => o.Rows)
                                .SingleOrDefault();

            originalOrder.Rows.ToList().ForEach(r => _context.Entry(r).State = EntityState.Deleted);

            await _context.SaveChangesAsync();

            foreach (var orderRow in order.Rows)
            {
                orderRow.Id = 0;

                _context.OrderRows.Add(orderRow);
            }

            await _context.SaveChangesAsync();

            _context.Entry(originalOrder).CurrentValues.SetValues(order);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
 public void Edit(T entity)
 {
     _db.Entry(entity).State = EntityState.Modified;
 }