Exemplo n.º 1
0
        public async Task <IActionResult> PutCliente([FromRoute] int id, [FromBody] Cliente cliente)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cliente.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                _repo.Update(cliente);
                var save = await _repo.SaveAsync(cliente);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClienteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
 public virtual void Atulizar(TEntity entity)
 {
     _context.Entry(entity).State = EntityState.Modified;
     _context.SaveChanges();
 }
 /// <summary>
 ///     Atualizar um registro
 /// </summary>
 /// <param name="entity">Entity</param>
 public void Update(T entity)
 {
     _context.Entry(entity).State = EntityState.Modified;
     _context.SaveChanges();
 }