Ejemplo n.º 1
0
        public string Search([FromBody] PersonSearchModel search)
        {
            var term        = search.Name;
            var peopleModel = new List <PersonModel>();

            try
            {
                var people = _bll.GetPeopleByName(term);
                peopleModel = people.Select(i =>
                                            new PersonModel {
                    First = i.First, Last = i.Last, Address = i.Address, Age = i.Age, Interest = i.Interests, Picture = i.Picture
                }).ToList <PersonModel>();;

                return(JsonConvert.SerializeObject(new Response
                {
                    State = RequestState.Success,
                    Msg = "",
                    Data = peopleModel
                }));
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(new Response
                {
                    State = RequestState.Failed,
                    Msg = ex.Message,
                    Data = null
                }));
            }
        }