Пример #1
0
        public async Task <List <GetContactDTO> > GetAll()
        {
            var contacts = await _dbContext.Contacts.Select(contact =>
                                                            GetContactDTO.FromContact(contact)
                                                            ).ToListAsync();

            await _dbContext.SaveChangesAsync();

            return(contacts);
        }
Пример #2
0
        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));
        }