public EntregaEfectivoViewModel() { this.FormasPago = new ObservableCollection <Models.CajaFormaPagoEntrega>(); this.PropertyChanged += EntregaEfectivoViewModel_PropertyChanged; if (!this.IsInDesignMode) { _proxy = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IAdminServiceAsync>(); _pdata = CommonServiceLocator.ServiceLocator.Current.GetInstance <Common.ServiceContracts.IDataServiceAsync>(); this.Data = _proxy.GetEntrega(this.Sucursal.Clave, this.Cajero.Id); if (this.Data != null) { foreach (var item in this.Data.FormasPago) { var fitem = new Models.CajaFormaPagoEntrega { CajaFormaPago = item }; fitem.PropertyChanged += (sender, e) => { this.SaveCommand.RaiseCanExecuteChanged(); }; this.FormasPago.Add(fitem); } } } this.SaveCommand = new RelayCommand(() => { //var code = Microsoft.VisualBasic.Interaction.InputBox("Codigo Auditor:"); //var isValid = _proxy.ValidarCodigo(this.Auditor.Id, code); //if (!isValid) //{ // MessageBox.Show("Código no valido.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); // return; //} var request = new Common.Entities.EntregaRequest { Sucursal = this.Sucursal.Clave, CajeroId = this.Cajero.Id, AuditorId = this.Auditor.Id, Entregar = this.Entrega.Value, FormasPago = this.FormasPago.Select(i => new Common.Entities.EntregaFormaPago { FormaPago = i.CajaFormaPago.FormaPago, Entregar = i.Entregar.Value, Amount = i.EntregarMonto.Value }) }; _proxy.Entrega(request); MessageBox.Show("ready"); this.CloseCommand.Execute(null); }, () => this.Auditor != null && this.Entrega.HasValue && this.FormasPago.All(i => i.Entregar.HasValue && i.EntregarMonto.HasValue)); this.LoadAuditorCommand = new RelayCommand(() => { this.Auditor = _pdata.FindAuditorEntrega(this.SearchAuditor.Value, this.Cajero.Id); if (this.Auditor != null) { this.SearchAuditor = null; } }, () => this.SearchAuditor.HasValue); if (this.IsInDesignMode) { this.SearchAuditor = 100; this.Auditor = new Common.Entities.Empleado { Nombre = "nombre", ApellidoMaterno = "materno", ApellidoPaterno = "paterno", Puesto = (int)Common.Constants.Puesto.SUP }; this.Data = new Common.Entities.CajaFormas { Efectivo = 1099m, FormasPago = new Common.Entities.CajaFormaPago[] { new Common.Entities.CajaFormaPago { FormaPago = Common.Constants.FormaPago.TC, Unidades = 3, Monto = 299m }, new Common.Entities.CajaFormaPago { FormaPago = Common.Constants.FormaPago.VA, Unidades = 100, Monto = 10999m }, new Common.Entities.CajaFormaPago { FormaPago = Common.Constants.FormaPago.CP, Unidades = 1000, Monto = 1000000m } } }; foreach (var item in this.Data.FormasPago) { this.FormasPago.Add(new Models.CajaFormaPagoEntrega { CajaFormaPago = item }); } this.Entrega = 456.7m; } }