コード例 #1
0
        public async Task <ActionResult <Contact> > GetContact(long id)
        {
            var contact = await _context.GetContact(id);

            if (contact == null)
            {
                return(NotFound());
            }
            return(contact);
        }
コード例 #2
0
        public async Task <IActionResult> GetContact(Int64 id)
        {
            try
            {
                var data = await contactLogic.GetContact(id);

                if (data == null)
                {
                    //return NotFound();  // Content(HttpStatusCode.NotFound, "Contact not found");
                    return(StatusCode(StatusCodes.Status404NotFound, "Contact not found"));
                }

                return(Ok(data));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving data from the database"));
            }
        }