Beispiel #1
0
        public async Task <ActionResult <Lot> > DequeueLot()
        {
            // Check if plant 1 is full
            if (await m_lotRepository.IsNextFullAsync(0))
            {
                return(BadRequest("Next plant is full"));
            }

            // Get first lot in the queue
            Lot first = inventory.ElementAt(0);

            if (first == null)
            {
                return(BadRequest("Unable to dequeue lot"));
            }

            // Dequeue first lot
            var success = await m_inventoryRepository.DequeueLotAsync(first.UserLot);

            if (Convert.ToBoolean(success))
            {
                // Remove lot from queue and set plant location to plant 1
                inventory.Remove(first);
                first.PlantId = 1;
            }
            else
            {
                return(BadRequest("Unable to dequeue lot"));
            }

            return(first);
        }