Пример #1
0
        // Method finding particular key specified by user:
        protected virtual void ShowSpecifiedKey()
        {
            DialogBoxFactory dialogFactory = new DialogBoxFactory();
            RequestDialogBox dialogBox;
            RoomKey          key;
            string           id;

            // dialog box building part:
            dialogFactory.HeaderMessage       = "Proszę podać numer szukanego klucza.";
            dialogFactory.RequestedParameters = new List <string>()
            {
                "Numer Identyfikacyjny"
            };
            dialogFactory.DefaultValuesForRequestedParameters = new List <string>();
            dialogFactory.CorrespondingRules = new List <ValidationRules> {
                ValidationRules.StringTyped4DigitCode
            };

            dialogBox = dialogFactory.GetRequestDialogBox();
            // dialog box handling part:
            if ((bool)dialogBox.ShowDialog())
            {
                id = dialogBox[0];
            }
            else
            {
                return;
            }
            // data access part
            try
            {
                key = _queryProvider.GetRoomKeyByIdAsync(id).Result;
            }
            catch (Exception e)
            {
                SendTabNotification(new TabNotificationSentEventArgs()
                {
                    Message = e.Message
                });
                return;
            }
            // data validation part:
            if (key == null)
            {
                DialogBoxFactory.GetInfoBox($"Brak wyników. Klucz o numerze: {id} nie istnieje w Bazie.").Show();
                ResetKeysCollection();
            }
            else
            {
                ResetKeysCollection(new List <RoomKey>()
                {
                    key
                });
            }
            ResetPresentedDetail();
        }
Пример #2
0
        // Handover room key procedure algorithm:
        protected virtual void HandoverTheKey()
        {
            RoomKey searchedKey;
            string  requestedKeyId = UI_RequestId("Proszę podać numer klucza:"); // requesting an id parameter

            if (requestedKeyId == null)                                          // Triggers when user cancels providing requested informations.
            {
                DialogBoxFactory.GetInfoBox("Procedura anulowana!").Show();
                return;
            }

            try // potential exception handler
            {
                searchedKey = _dataQueryProvider.GetRoomKeyByIdAsync(requestedKeyId).Result;
            }
            catch (Exception e)
            {
                SendTabNotification(new TabNotificationSentEventArgs()
                {
                    Message = e.Message
                });
                return;
            }

            if (searchedKey == null) // Triggers when user provided wrong key id.
            {
                DialogBoxFactory.GetInfoBox("Klucz nie został odnaleziony w Bazie.").Show();
                return;
            }
            else if (searchedKey.AssignedEmployee_Id != null) // Triggers when user provided id of key which was already handovered.
            {
                DialogBoxFactory.GetInfoBox("Klucz został już wydany innemu pracownikowi.").Show();
                return;
            }
            else // Triggers when user provided correct key id and key was found on gatehouse.
            {
                try // potential exception handler
                {
                    _dataCommandProvider.HandOverTheRoomKeyToEmployeeAsync(searchedKey, RegisteredEmployee.GetRegisteredEmployee()).Wait();
                }
                catch (Exception e)
                {
                    SendTabNotification(new TabNotificationSentEventArgs()
                    {
                        Message = e.Message
                    });
                    return;
                }
                DialogBoxFactory.GetInfoBox("Wydano klucz!").Show();                                                      // Handover key operation confirmation.
            }
            RegisteredEmployee.RefreshHeldKeys(DB_RequestEmployeesOwnedKeys(RegisteredEmployee.GetRegisteredEmployee())); // Refresh information about taken keys by registered employee.
            RaisePropertyChangedEvent(nameof(RegisteredEmployee));                                                        // Informing the view.
        }