예제 #1
0
        public async Task <ActionResult <ContactDto> > GetContact(int id)
        {
            try
            {
                Contact contactFromRepo = await _repository.GetContact(id);

                if (contactFromRepo == null)
                {
                    return(NotFound());
                }

                ContactDto contact = _mapper.Map <ContactDto>(contactFromRepo);

                return(Ok(contact));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }