Esempio n. 1
0
        private int GetEquipmentFreeId()
        {
            var addIds = equipmentRepository.GetAllIds();

            if (addIds.Count == 0)
            {
                return(0);
            }
            addIds.Sort();
            var lastId = addIds.Last();

            if (addIds.Count != lastId)
            {
                for (var i = 0; i < lastId; i++)
                {
                    if (addIds.Contains(i))
                    {
                        continue;
                    }
                    return(i);
                }
            }
            return(lastId + 1);
        }