コード例 #1
0
        [Route("list")] //url: /api/person/list
        public HttpResponseMessage List()
        {
            try
            {
                var personsList = new List <PersonModelConsultation>();

                foreach (Person p in appPerson.FindAll())
                {
                    personsList.Add(Mapper.Map <Person, PersonModelConsultation>(p));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, personsList));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }