public async Task <IActionResult> Post(ContactoDepartamento contacto) { try { _context.ContactoDepartamento.Add(contacto); await _context.SaveChangesAsync(); return(new OkObjectResult(contacto)); } catch (DbUpdateException ex) { return(new BadRequestObjectResult(ex.InnerException.Message)); } }
public async Task <IActionResult> Put(ContactoDepartamento contact, int id) { try { var existing = _context.ContactoDepartamento.Where(s => s.Id == id).FirstOrDefault(); existing.IdContacto = contact.IdContacto; existing.IdDepartamento = contact.IdDepartamento; existing.Habilitado = contact.Habilitado; await _context.SaveChangesAsync(); return(new OkResult()); } catch (DbUpdateConcurrencyException ex) { return(new BadRequestObjectResult(ex.InnerException.Message)); } }
public async Task <IActionResult> Put([FromBody] ContactoDepartamento _contact, int id) { return(await contact.Put(_contact, id)); }
public async Task <IActionResult> Post([FromBody] ContactoDepartamento _contact) { return(await contact.Post(_contact)); }