public async Task <ActionResult <Contato> > ApagarContatoPorId(int id,
                                                                       [FromServices] ContatoContext context)
        {
            try
            {
                var contato = await context.Contatos
                              .FirstOrDefaultAsync(x => x.ContatoID == id);

                context.Remove(contato);
                await context.SaveChangesAsync();

                return(Ok());
            }
            catch (System.Exception)
            {
                return(NotFound());

                throw;
            }
        }
Ejemplo n.º 2
0
 public virtual void Delete(TEntity obj)
 {
     _context.Remove(obj);
     _context.SaveChanges();
 }