public async Task <List <GetContactDTO> > GetAll() { var contacts = await _dbContext.Contacts.Select(contact => GetContactDTO.FromContact(contact) ).ToListAsync(); await _dbContext.SaveChangesAsync(); return(contacts); }
public async Task <GetContactDTO> Get(Guid id) { var contact = await _dbContext.Contacts.FirstOrDefaultAsync(); await _dbContext.SaveChangesAsync(); if (contact == null) { throw new NotFoundException(); } return(GetContactDTO.FromContact(contact)); }