using Gestor.Application.Servicos.Financeiro; using Gestor.Application.Servicos.Generic; using Gestor.Application.ViewModels.Generic; using Gestor.Model.Domain.Financeiro; using Gestor.Model.Domain.Generic; using System; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.CompilerServices; using System.Threading.Tasks; namespace Gestor.Application.ViewModels.Financeiro { public class InfoExtratoViewModel : BaseFinanceiroViewModel { private readonly BancosContasServico _saldoServico; private Saldo _selectedSaldo; public bool _telaBancos { get; set; } public Saldo SelectedSaldo { get { return this._selectedSaldo; } set { if (value != null && !this._telaBancos) { value.set_DataFinal(null); value.set_ValorFinal(null); } this._selectedSaldo = value; base.OnPropertyChanged("SelectedSaldo"); this.SelectedSaldo.Initialize(); } } public InfoExtratoViewModel(bool telaBancos) { this._telaBancos = telaBancos; this._saldoServico = new BancosContasServico(); } public async Task>> Salvar() { List> keyValuePairs; List> keyValuePairs1 = this.SelectedSaldo.Validate(); if (keyValuePairs1.Count <= 0) { if (!this._telaBancos) { this.SelectedSaldo.set_DataFinal(null); this.SelectedSaldo.set_ValorFinal(null); } this.SelectedSaldo = await this._saldoServico.Save(this.SelectedSaldo); if (this._saldoServico.Sucesso) { base.Alterar(false); base.ToggleSnackBar("SALDO SALVO COM SUCESSO", true); keyValuePairs = null; } else { keyValuePairs = null; } } else { keyValuePairs = keyValuePairs1; } return keyValuePairs; } } }