Ejemplo n.º 1
0
        public void RequestEntry(String id)
        {
            //Door is closed and ready for new request
            switch (_doorControlStates)
            {
            case DoorControlStates.DoorClosed:
                //Validate user
                if (!_userValidation.ValidateEntryRequest(id))
                {
                    return;
                }

                //Change state
                _doorControlStates = DoorControlStates.DoorOpening;

                //Open door
                _door.Open();

                //Notify user
                _entryNotification.NotifyEntryGranted();

                //End case
                break;

            //Alarm is currently active, userValidation disables alarm
            case DoorControlStates.DoorAlarm:
                //Validate user
                if (!_userValidation.ValidateEntryRequest(id))
                {
                    return;
                }

                //Change state
                _doorControlStates = DoorControlStates.DoorClosed;

                //Lower alarm
                _alarm.Lower();

                //End case
                break;
            }
        }