public ThingEnd GetThingEnd(long thingID, long thingEndpointTypeID)
        {
            ThingEnd tngEnd = new ThingEnd();
            List<GetThingEnds_Result> queryResult = db.GetThingEnds(null, thingID, null, null, thingEndpointTypeID).ToList();

            ThingEnd thingEnd = new ThingEnd();
            thingEnd.ConvertFromQuery_GetThingEndsList(queryResult[0]);
            return thingEnd;
        }
        public IPagedList GetThingEndsList(string searchFor ="" ,long ?locationID = null, long ?thingID = null,long ?thingCategoryID = null, long ?endpointTypeID = null,long ?endPointID = null, int pageNumber = 1, int recordsPerPage = 0)
        {
            
            List<GetThingEnds_Result> queryResult = db.GetThingEnds(locationID,thingID,thingCategoryID,endPointID,endpointTypeID).Where(x => x.ThingTitle.Contains(searchFor)).ToList();
            List<ThingEnd> thingEnds = new List<ThingEnd>();


            foreach (GetThingEnds_Result res in queryResult)
            {
                ThingEnd thingEnd = new ThingEnd();
                thingEnd.ConvertFromQuery_GetThingEndsList(res);
                thingEnds.Add(thingEnd);
            }

            return thingEnds.ToPagedList(pageNumber, recordsPerPage);
        }