public async Task <ActionResult> PostContactType(ContactTypeCreateDTO contactTypeCreateDTO) { try { var contactType = new ContactType { Description = contactTypeCreateDTO.Description }; _context.ContactTypes.Add(contactType); await _context.SaveChangesAsync(); } catch (DbUpdateException ex /* ex */) { _logger.LogError(ex.ToString()); return(BadRequest(ex)); } return(NoContent()); }
public async Task <IActionResult> PutContactType(int id, ContactTypeCreateDTO contactTypeCreateDTO) { if (!ContactTypeExists(id)) { return(NotFound()); } var contactType = new ContactType { Id = id, Description = contactTypeCreateDTO.Description, UpdatedAt = DateTime.UtcNow }; _context.Entry(contactType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(BadRequest()); } return(NoContent()); }