示例#1
0
        public IActionResult CheckIfPinIsValid(PinViewModel model)
        {
            if (!this.ModelState.IsValid || model.Name == null)
            {
                model.MessageText = string.Format(WebConstants.EnterValidData, model.Name);

                return(View(model));
            }

            var isSucceeded = this.pinService.isValidPin(model.Name);

            if (isSucceeded)
            {
                model.MessageText = string.Format(WebConstants.PinIsValid, model.Name);
                model.IsValid     = true;

                return(View(model));
            }
            else
            {
                model.MessageText = string.Format(WebConstants.PinIsNotValid, model.Name);

                return(View(model));
            }
        }
示例#2
0
        public async Task <IActionResult> Create(PinViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.GetUserAsync(User);

                string    imagePath     = null;
                IFormFile uploadedImage = model.Image;
                if (uploadedImage != null && uploadedImage.ContentType.ToLower().StartsWith("image/"))
                {
                    imagePath = "/images/pins/" + user.UserName + DateTime.Now.ToString("yyyyMMddHHmmssffffff") + uploadedImage.FileName;
                    using (var fileStream = new FileStream(_env.WebRootPath + imagePath, FileMode.Create))
                    {
                        await uploadedImage.CopyToAsync(fileStream);
                    }
                }
                Pin pin = new Pin
                {
                    Title = model.Title,
                    Image = imagePath
                };
                pin.Board = await _db.Boards.FirstOrDefaultAsync(p => p.Title == model.BoardTitle);

                _db.Pins.Add(pin);
                await _db.SaveChangesAsync();

                _logger.LogInformation($"Added pin {pin.Title}");
            }
            return(RedirectToAction("Index", "Board"));
        }
        public void TestNobPositiveTargetPinLengthException()
        {
            var pinViewModel = new PinViewModel();

            Assert.Throws <ArgumentException>(() => { pinViewModel.TargetPinLength = -2; });
            Assert.Throws <ArgumentException>(() => { pinViewModel.TargetPinLength = 0; });
        }
        public async void DeleteRecord(RecordListInfo context)
        {
            var result = await ShowConfirmation("Usuwanie inwentaryzacji",
                                                "Ta operacja spowoduje usunięcie wszystkich inwentaryzacji na dzień " +
                                                context.RecordDate.ToRecordDateString() + Environment.NewLine +
                                                "Czy chcesz kontynuować?", showOnParentScreen : true);

            if (result == MessageDialogResult.Negative)
            {
                return;
            }

            var pinViewModel = new PinViewModel();

            var pinResult = ShowDialog(pinViewModel);

            if (pinResult == null || pinResult == false)
            {
                return;
            }

            if (pinViewModel.IsPinValid)
            {
                IoC.Get <IRecordsManager>().DeleteRecord(context);
                LoadData();
            }
            else
            {
                await ShowMessage("Nieprawidłowy PIN", "Podany PIN jest nieprawidłowy", true);
            }
        }
        private async void OnTapOnCell(PinViewModel pinViewModel)
        {
            NavigationParameters pinParametrs = new NavigationParameters();

            pinParametrs.Add("SelectedItemInListView", pinViewModel);
            await NavigationService.NavigateAsync(nameof(MapTabbedView), pinParametrs);
        }
        private async void OnEditPinInList(PinViewModel pin)
        {
            NavigationParameters pinForEdit = new NavigationParameters();

            pinForEdit.Add("PinForEdit", pin);
            await NavigationService.NavigateAsync(nameof(AddPinView), pinForEdit);
        }
示例#7
0
 public Pin(PinViewModel model)
 {
     InitializeComponent();
     this.model       = model;
     this.DataContext = model;
     txtPin.Focus();
 }
示例#8
0
        public override void OnNavigatedTo(INavigationParameters parameters)
        {
            if (parameters.TryGetValue(Constants.NavigationParameters.PinSettings, out PinModel pin))
            {
                CurrentPin        = pin.ToViewModel();
                _updatePin        = true;
                ToolbarButtonText = AppResources.Update;
                MapCameraPosition = new CameraPosition(new Position(CurrentPin.Latitude, CurrentPin.Longitude), 5);
                Pins.Add(CurrentPin.ToPin());
            }
            else
            {
                CurrentPin = new PinViewModel()
                {
                    Name        = string.Empty,
                    UserID      = App.CurrentUserId,
                    Latitude    = 1.3541171,
                    Longitude   = 103.8659237,
                    IsFavorite  = true,
                    Description = string.Empty
                };

                MapCameraPosition = new CameraPosition(new Position(CurrentPin.Latitude, CurrentPin.Longitude), 5);
                Pins.Add(CurrentPin.ToPin());
            }
        }
 public void SetPinViewModelToState(PinViewModel pinView, int state, bool?visible)
 {
     if (state == 1)
     {
         pinView.ColourType = PinDisplayType.NOT_VISIBLE;
         pinView.ShowCircle = false;
     }
     else if (state == 2)
     {
         if (visible == false)
         {
             pinView.ColourType = PinDisplayType.NOT_VISIBLE;
             pinView.ShowCircle = false;
         }
         else
         {
             pinView.ColourType = PinDisplayType.LOCKED;
             pinView.ShowCircle = true;
         }
     }
     else if (state == 3)
     {
         pinView.ColourType = PinDisplayType.UNLOCKED;
         pinView.ShowCircle = false;
     }
 }
        public void TestincorrectPin()
        {
            var targetPin = new[] { '1', '2', '3', '4' };
            var viewModel = new PinViewModel
            {
                TargetPinLength = 4,
                ValidatorFunc   = (IList <char> arg) => Enumerable.SequenceEqual(targetPin, arg)
            };
            var view = new PinView
            {
                BindingContext = viewModel
            };
            Func <string, PinItemView> findButton = (string arg) =>
            {
                return((PinItemView)((Grid)view.Content).Children.First(c => c is PinItemView btn && btn.Text == arg));
            };

            Assert.Raises <EventArgs>(
                (EventHandler <EventArgs> obj) => viewModel.Error += obj,
                (EventHandler <EventArgs> obj) => viewModel.Error -= obj,
                () =>
            {
                foreach (char next in targetPin.Reverse())
                {
                    PinItemView btn = findButton(next.ToString());
                    btn.Command.Execute(btn.CommandParameter);
                }
            }
                );
        }
示例#11
0
        public CreateAuthPage(Account OldAccount)
        {
            string first  = "";
            string second = "";

            PinViewModel = new PinViewModel
            {
                TargetPinLength = 6,
                ValidatorFunc   = (arg) =>
                {
                    second = "";
                    foreach (char c in arg)
                    {
                        second += c;
                    }

                    if (second.Equals(first))
                    {
                        Account acc = new Account(first);
                        acc.Properties.Add("FingerPrint", OldAccount.Properties["FingerPrint"]);
                        if (OldAccount.Properties.ContainsKey("PrivateKey"))
                        {
                            acc.Properties.Add("PrivateKey", OldAccount.Properties["PrivateKey"]);
                        }
                        AccountStore.Create().Delete(OldAccount, App.AppName);
                        AccountStore.Create().Save(acc, App.AppName);
                        App.Current.Properties["Pin"] = acc;
                        Navigation.PopToRootAsync();
                        return(true);
                    }
                    else
                    {
                        if (first.Equals(""))
                        {
                            first    += second;
                            PIN.Title = "Confirm your pin";
                        }
                        else
                        {
                            DisplayAlert("Error", "Passcode doesn't match.\nTry it again.", "OK");
                            first     = "";
                            second    = "";
                            PIN.Title = "Create your pin";
                        }
                        return(false);
                    }
                }
            };

            PIN = new PinView
            {
                Title             = "Create your pin",
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                BindingContext    = PinViewModel,
            };

            Content = PIN;
        }
示例#12
0
        public PinDialog(PinViewModel vm)
        {
            InitializeComponent();

            vm.ViewModelUpdated += PinView_ViewModelUpdated;
            vm.PasswordsCleared += PinView_PasswordsCleared;
            DataContext          = vm;
        }
示例#13
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;


            PinViewModel mdl = button.DataContext as PinViewModel;

            SetUp(mdl, false);
        }
示例#14
0
 public static Pin ToPin(this PinViewModel pinViewModel)
 {
     return(new Pin
     {
         Label = pinViewModel.PinName,
         Position = new Position(pinViewModel.PinLatitude, pinViewModel.PinLongitude),
         Tag = pinViewModel.PinDescription
     });
 }
示例#15
0
        public PinAuthViewModel(Page context, CommonPageSettings pageSettings, bool isReset)
        {
            _context               = context;
            _pinViewModel          = new PinViewModel();
            this.IsCustomHeader    = pageSettings.IsShowCustomHeader;
            _pinViewModel.Error   += (object sender, EventArgs e) => { IsInvalid = true; };
            _pinViewModel.Success += (object sender, PinEventArgs e) => { IsInvalid = false; };

            IsReset = isReset;
        }
        public void TestTargetPinLengthPropertyChangedRaised()
        {
            var pinViewModel  = new PinViewModel();
            int expectedValue = 3;

            Assert.PropertyChanged(pinViewModel,
                                   nameof(PinViewModel.TargetPinLength),
                                   () => pinViewModel.TargetPinLength = expectedValue);
            Assert.Equal(expectedValue, pinViewModel.TargetPinLength);
        }
        public void TestValidatorFuncPropertyChangedRaised()
        {
            var pinViewModel  = new PinViewModel();
            var expectedValue = new Func <IList <char>, bool>((arg) => false);

            Assert.PropertyChanged(pinViewModel,
                                   nameof(PinViewModel.ValidatorFunc),
                                   () => pinViewModel.ValidatorFunc = expectedValue);
            Assert.Same(expectedValue, pinViewModel.ValidatorFunc);
        }
示例#18
0
        private async void OnDeletePinFromList(PinViewModel pin)
        {
            var userAnsver = await _pageDialogService.DisplayAlertAsync("Delete", "Do you want delete pin?", "Yes", "No");

            if (userAnsver)
            {
                _pinModelService.DeletePin(pin.ToPinModel());
                var newList = _pinModelService.GetAllPins();
                Pins = new ObservableCollection <PinViewModel>(newList.Select(x => x.ToPinViewModel()));
            }
        }
示例#19
0
        public PinAuthViewModel()
        {
            string pinAsString = LorikeetMApp.Helpers.Settings.Pin;

            _correctPin   = new[] { pinAsString[0], pinAsString[1], pinAsString[2], pinAsString[3] };
            _pinViewModel = new PinViewModel
            {
                TargetPinLength = 4,
                ValidatorFunc   = (arg) => Enumerable.SequenceEqual(arg, _correctPin)
            };
        }
        public void TestEnteredPinPropertyChangedRaised()
        {
            var pinViewModel  = new PinViewModel();
            var expectedValue = new List <char> {
                'a', 'b'
            };

            Assert.PropertyChanged(pinViewModel,
                                   nameof(PinViewModel.EnteredPin),
                                   () => pinViewModel.EnteredPin = expectedValue);
            Assert.Same(expectedValue, pinViewModel.EnteredPin);
        }
示例#21
0
        public static Pin ToPin(this PinViewModel pinViewModel)
        {
            var pin = new Pin()
            {
                Label     = pinViewModel.Label,
                Position  = new Position(pinViewModel.Latitude, pinViewModel.Longitude),
                Address   = pinViewModel.Address,
                IsVisible = pinViewModel.IsFavorite
            };

            return(pin);
        }
        private (Boolean dialogResultOk, string pin) AskForPin()
        {
            var pinModel = new PinViewModel();

            this.Cursor = Cursors.Wait;
            var w = new Pin(pinModel);

            w.Owner = this;
            var result = w.ShowDialog();

            return(result.HasValue ? result.Value : false, pinModel.Pin);
        }
        public void TestBackspacePressed()
        {
            var pinViewModel = new PinViewModel();

            pinViewModel.TargetPinLength = 5;
            pinViewModel.ValidatorFunc   = new Func <IList <char>, bool>((arg) => false);
            pinViewModel.KeyPressCommand.Execute("1");
            pinViewModel.KeyPressCommand.Execute("1");
            pinViewModel.KeyPressCommand.Execute("2");
            pinViewModel.KeyPressCommand.Execute("Backspace");
            Assert.True(Enumerable.SequenceEqual(new[] { '1', '1' }, pinViewModel.EnteredPin));
        }
示例#24
0
    public void CreatePin(EmotionType type)
    {
        _pin = GameObject.Instantiate(PinPrefab);
        _pin.transform.SetParent(this.transform, false);

        string       ty = type.ToString();
        PinViewModel vm = _pin.GetComponent <PinViewModel>();

        vm.EmotionIcon.sprite = Resources.Load <Sprite>("Sprites/" + type.ToString());

        StartCoroutine(DestroyPin());
    }
示例#25
0
 private void AddUserPushpin()
 {
     if (userPushpin == null)
     {
         userPushpin = new PinViewModel("me")
         {
             IsCustom = true
         };
         stopMap.Center = geoWatch.Position.Location;
     }
     userPushpin.Location = geoWatch.Position.Location;
     App.ViewModel.SearchPins.Add(userPushpin);
 }
 public PinAuthViewModel()
 {
     _correctPin   = new[] { '1', '2', '3', '4' };
     _pinViewModel = new PinViewModel
     {
         TargetPinLength = 4,
         ValidatorFunc   = (arg) => Enumerable.SequenceEqual(arg, _correctPin)
     };
     _pinViewModel.Success += (object sender, EventArgs e) =>
     {
         Debug.WriteLine("Success. Assume page will be closed automatically.");
     };
 }
示例#27
0
 private void OnPreviewPinMouseDown(PinViewModel pinViewModel, MouseButtonEventArgs e)
 {
     if (pinViewModel.Pin.Direction != PinDirection.Input)
     {
         _endLinkPoint = ViewModel.BeginLinkage(pinViewModel);
         CaptureMouse();
     }
     else
     {
         _endLinkPoint = ViewModel.BeginRelinkage(pinViewModel);
         CaptureMouse();
     }
 }
示例#28
0
        private void SetUp(PinViewModel mdl, bool isPermo)
        {
            MadLed.MadLedDevice.PinConfig pc = new MadLed.MadLedDevice.PinConfig
            {
                Name        = mdl.Name + "\r",
                DeviceClass = mdl.DeviceClass,
                Pin         = mdl.Pin,
                LedCount    = mdl.LedCount
            };

            var pcfg = madLedDevice.SetConfigCmd(mdl.Pin, pc);

            if (isPermo)
            {
                pcfg[1] = 2;
            }

            //madLedDevice.stream.Write(pcfg,0,pcfg.Length);
            madLedDevice.SendPacket(madLedDevice.stream, pcfg);

            //madLedDevice.ReadReturnReport(madLedDevice.stream);
            if (mdl.LedCount > 0 && pc.DeviceClass > -1)
            {
                MadLed.MadLedControlDevice mlcd = new MadLed.MadLedControlDevice
                {
                    DeviceType   = MadLed.deviceTypes[pc.DeviceClass],
                    Name         = pc.Name,
                    MadLedDevice = madLedDevice,
                    LEDs         = new ControlDevice.LedUnit[pc.LedCount],
                    Driver       = MadLed,
                    Pin          = mdl.Pin
                };

                for (int p = 0; p < pc.LedCount; p++)
                {
                    mlcd.LEDs[p] = new ControlDevice.LedUnit
                    {
                        Data = new ControlDevice.LEDData
                        {
                            LEDNumber = p
                        },
                        LEDName = "LED " + (p + 1),
                        Color   = new LEDColor(0, 0, 0)
                    };
                }

                MadLed.InvokeAdded(mlcd);
            }

            //DeviceAdded?.Invoke(this, new Events.DeviceChangeEventArgs(mlcd));
        }
示例#29
0
 public static PinModel ToPinModel(this PinViewModel pinViewModel)
 {
     return(new PinModel
     {
         Id = pinViewModel.Id,
         UserId = pinViewModel.UserId,
         PinName = pinViewModel.PinName,
         Description = pinViewModel.PinDescription,
         Latitude = pinViewModel.PinLatitude,
         Longitude = pinViewModel.PinLongitude,
         Categories = pinViewModel.PinCategories,
         FavoritPin = pinViewModel.FavoritPin,
     });
 }
示例#30
0
        private void SetAsUnlockedWithoutActions()
        {
            if (State == 3)
            {
                return;
            }

            if (FirstlyUnlocked)
            {
                if (Model.PositionsDisplayAfterUnlock != null)
                {
                    MapService.AddNotStops(Model.PositionsDisplayAfterUnlock as List <MapPosition>);
                }

                if (Model.DisplayObjectsRewards != null)
                {
                    foreach (DisplayObjectStopDisplayAfterUnlock displayObject in Model.DisplayObjectsRewards)
                    {
                        ViewModel.AddDisplayObject(displayObject.DisplayObject, (int)displayObject.Position);
                    }
                }
                FirstlyUnlocked = false;
            }


            if (Model.Position != null && PinOfTheStop == null)
            {
                PinOfTheStop = MapService.AddStop(Model.Position, 3, IsVisibleInState2);
            }
            else if (PinOfTheStop != null)
            {
                MapService.SetPinViewModelToState(PinOfTheStop, 3, IsVisibleInState2);
            }

            if (State == 2)
            {
                foreach (PasswordService password in Passwords)
                {
                    password.Unshow();
                }
            }

            State = 3;

            if ((bool)Model.IsFinal)
            {
                GameService.End();
            }
        }