Esempio n. 1
0
        public NotaRevisionViewModel()
        {
            this.Items   = new ObservableCollection <Common.Entities.NoteHeader>();
            this.Details = new ObservableCollection <Common.Entities.NoteDetalle>();
            this.Details.CollectionChanged += Details_CollectionChanged;
            this.LoadCommand = new GalaSoft.MvvmLight.Command.RelayCommand(() =>
            {
                this.Loaded = this.Selected;
                var items   = _data.GetNoteDetails(this.Loaded.Id);
                this.Details.Clear();
                foreach (var item in items)
                {
                    this.Details.Add(item);
                }
            }, () => this.Selected != null);
            this.SaveCommand = new GalaSoft.MvvmLight.Command.RelayCommand(async() =>
            {
                var item = await _process.RegisterNoteAsync(this.Loaded.Id);
                this.Items.Remove(this.Loaded);
                this.Details.Clear();
                this.Loaded = null;
                MessageBox.Show($"id: {item}");
            }, () => this.Loaded != null);
            this.PropertyChanged += NotaRevisionViewModel_PropertyChanged;
            if (this.IsInDesignMode)
            {
                this.Items.Add(new Common.Entities.NoteHeader {
                    Id = 1, Date = DateTime.Now, Sucursal = "08", CajeroId = 10, Total = 100
                });
                this.Items.Add(new Common.Entities.NoteHeader {
                    Id = 1, Date = DateTime.Now, Sucursal = "08", CajeroId = 10, Total = 100
                });
                this.Items.Add(new Common.Entities.NoteHeader {
                    Id = 1, Date = DateTime.Now, Sucursal = "08", CajeroId = 10, Total = 100
                });
                this.Selected = this.Items[0];
                this.Loaded   = this.Items[1];

                this.Details.Add(new Common.Entities.NoteDetalle {
                    Serie = "s1", Amount = 100, Comments = "commnets"
                });
                this.Details.Add(new Common.Entities.NoteDetalle {
                    Serie = "s1", Amount = 100, Comments = "commnets"
                });
            }
            else
            {
                _data    = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>();
                _process = CommonServiceLocator.ServiceLocator.Current.GetInstance <Helpers.ServiceClient>();

                var items = _data.GetNotes();
                foreach (var item in items)
                {
                    this.Items.Add(item);
                }
            }
        }