예제 #1
0
        public async Task <IActionResult> PutOrder(int id, Order order)
        {
            if (id != order.ID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #2
0
        //void IRep_Base<Cliente>.UpDateAsync(Cliente Entity)
        public async Task UpDateAsync(Cliente cliente)
        {
            CTX.Entry(cliente).State = EntityState.Modified;

            try
            {
                await CTX.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClienteExists(cliente.Id))
                {
                    throw new ArgumentException(
                              $"Nada encontrado para o cliente {cliente.Nome}.", nameof(cliente.Nome));
                }
                else
                {
                    throw;
                }
            }
        }
예제 #3
0
 public void UpDate(TEntity obj)
 {
     db.Entry(obj).State = EntityState.Modified;
     db.SaveChanges();
 }