コード例 #1
0
        public async Task <ActionResult <ContactReadDto> > GetContactAndContactDetails(int contactId, int contactDetailId)
        {
            try
            {
                bool contactExists = await _addressBookService.ContactExists(contactId);

                if (!contactExists)
                {
                    return(NotFound());
                }

                ContactDetail contactDetailFromService = await _addressBookService.GetContactDetail(contactId, contactDetailId);

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

                ContactReadDto contactReadDto = _mapper.Map <ContactReadDto>(contactDetailFromService.Contact);

                return(Ok(contactReadDto));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }