Example #1
0
        private async void PagoValeViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case nameof(this.Vale):
                this.RaisePropertyChanged(nameof(this.Expirado));
                this.AcceptCommand.RaiseCanExecuteChanged();
                if (!this.Vale?.Distribuidor?.ContraVale ?? false)
                {
                    this.GenerateContraVale = false;
                }
                break;

            case nameof(this.GenerateContraVale):
            case nameof(this.Limite):
                this.RaisePropertyChanged(nameof(this.ContraVale));
                this.AcceptCommand.RaiseCanExecuteChanged();
                break;

            case nameof(this.Pagar):
                this.UpdatePagos();
                this.RaisePropertyChanged(nameof(this.ContraVale));
                break;

            case nameof(this.SelectedPlazo):
                this.UpdatePagos();
                this.AcceptCommand.RaiseCanExecuteChanged();
                break;

            case nameof(this.SelectedPromocion):
                if (this.SelectedPromocion.HasValue)
                {
                    var ind     = this.Promociones.ToList().IndexOf(this.SelectedPromocion.Value);
                    var max     = this.PagosMax - ind;
                    var options = Enumerable.Range(1, max);
                    this.Plazos = options;
                }
                this.AcceptCommand.RaiseCanExecuteChanged();
                break;

            case nameof(this.ClientId):
            {
                this.Vale = await _proxy.FindValeDigitalByClientAsync(this.ClientId.Value);

                if (this.Vale != null)
                {
                    if (!this.Vale.Distribuidor.Promocion)
                    {
                        this.SelectedPromocion = this.Promociones.FirstOrDefault();
                    }
                }
            }
            break;
            }
        }