Exemple #1
0
        public static QueryResult <Person> GetById(int id)
        {
            var response = new QueryResult <Person>();

            try
            {
                var person = PersonDAO.GetById(id);

                if (person != null)
                {
                    response.Data = person;
                }
                else
                {
                    response.HasError   = true;
                    response.StatusCode = HttpStatusCode.NotFound;
                    response.Message    = $"The person with the ID {id} does not exist in the database";
                }
            }
            catch (Exception ex)
            {
                HandleError(response, ex);
            }

            return(response);
        }