public async Task <IActionResult> GetThindId(int?thingid)
        {
            if (thingid == null)
            {
                return(NotFound());
            }
            var productionOrder = await _productionOrderService.getProductionOrderOnThing(thingid.Value);

            if (productionOrder == null)
            {
                return(NotFound());
            }
            return(Ok(productionOrder));
        }
        public async Task <(ProductionOrder, string)> AssociateProductionOrder(int thingId, int productioOrderId)
        {
            var PO = await _productionOrderService.getProductionOrder(productioOrderId);

            if (PO == null)
            {
                return(null, "Production Order Not Found");
            }
            if (PO.currentStatus != stateEnum.active.ToString())
            {
                return(null, "Production Order must be Active to Be set in Production");
            }
            var POType = await _productionOrderTypeService.getProductionOrderType(PO.productionOrderTypeId.Value);

            if (POType == null)
            {
                return(null, "Production Order Type Not Found");
            }
            var POOnThing = await _productionOrderService.getProductionOrderOnThing(thingId);

            var  thingGroups = POType.thingGroups;
            bool contains    = false;

            foreach (var group in thingGroups)
            {
                var(completeGroup, status) = await _thingGroupService.getGroup(group.thingGroupId);

                if (status == HttpStatusCode.OK)
                {
                    if (completeGroup.things.Select(x => x.thingId).Contains(thingId) == true)
                    {
                        contains = true;
                    }
                }
            }
            if (!contains)
            {
                return(null, "This Production Order can't  be associated with this thing.");
            }
            await _productionOrderService.setProductionOrderToThing(PO, thingId);

            UpdateStatusAPI(POType.typeScope, POType.typeDescription, "productionOrderNumber", PO.productionOrderNumber, thingId);
            Trigger(PO);
            PO = await _productionOrderService.getProductionOrder(productioOrderId);

            return(PO, "Production Order Set to Thing");
        }