public async Task SubmitButton()
        {
            var deviceValidator  = new DeviceModelValidator();
            var validationResult = deviceValidator.Validate(Device);

            // For testing
            DeviceValidationResult = validationResult.IsValid;

            if (validationResult.IsValid)
            {
                var deviceEntity = await Device.ConvertToDeviceEntity();

                var resultTask = await _deviceAccess.UpdateDevice(deviceEntity);

                // For testing
                DeviceUpdateResult = resultTask;

                if (resultTask)
                {
                    _events.PublishOnUIThread(new DeviceCredentialsChangedEvent());
                    this.TryClose();
                }
                else
                {
                    MessageBox.Show("Wystąpił błąd podczas zapisu danych. Spróbuj ponownie");
                }
            }
            else
            {
                MessageBox.Show("Błąd walidacji danych");
            }
        }
Esempio n. 2
0
        public async void SaveButton()
        {
            var device = new DeviceModel(_producerAccess)
            {
                Name          = DeviceName,
                ArticleNumber = ArticleNumber,
                ProducerName  = SelectedProducerName,
                Location      = Location,
                Quantity      = Quantity
            };

            var deviceValidator = new DeviceModelValidator();
            var result          = deviceValidator.Validate(device);

            // For testing
            NewDeviceValidationResult = result.IsValid;

            if (result.IsValid)
            {
                var deviceEntity = await device.ConvertToDeviceEntity();

                deviceEntity.ProjectID = 5;
                SaveNewDeviceResult    = await _deviceAccess.AddDevice(deviceEntity);

                SnackbarNotification.MessageQueue = new SnackbarMessageQueue();
                string message = null;

                if (SaveNewDeviceResult)
                {
                    message = "Urządzenie zostało dodane poprawnie.";
                }
                else
                {
                    message = "Urządzenie nie zostało dodane.";
                }

                SnackbarNotification.MessageQueue.Enqueue(message);
                ClearDeviceForm();
            }
            else
            {
                SnackbarNotification.MessageQueue = new SnackbarMessageQueue();
                SnackbarNotification.MessageQueue.Enqueue("Błąd wprowadzonych danych, urządzenie nie zostało dodane.");
            }
        }
Esempio n. 3
0
        public async void SaveButton()
        {
            var device = new DeviceModel(_producerAccess)
            {
                Name          = DeviceName,
                ArticleNumber = ArticleNumber,
                ProducerName  = SelectedProducer,
                Location      = Location,
                Quantity      = Quantity
            };

            var deviceValidator = new DeviceModelValidator();
            var result          = deviceValidator.Validate(device);

            if (result.IsValid)
            {
                var deviceEntity = await device.ConvertToDeviceEntity();

                deviceEntity.ProjectID = ProjectId;
                var resultTask = await _deviceAccess.AddDevice(deviceEntity);

                if (resultTask)
                {
                    _events.PublishOnUIThread(new AddedNewDeviceToProjectEvent());
                    TryClose();
                }
                else
                {
                    MessageBox.Show("Urządzenie nie zostało dodane.");
                }
            }
            else
            {
                MessageBox.Show("Błąd walidacji danych");
            }
        }