Example #1
0
        public void Editar(Gastos gastos)
        {
            //Busco el gasto antiguo en la lista actual y después se lo reemplaza por el nuevo editado
            var gastoAntiguo = ListaGastos.Find(x => x.GastosId == gastos.GastosId);

            gastoAntiguo = gastos;
            dataService.Update(gastoAntiguo, true);
            SumaGastoCategoria = ListaGastos.Where(x => x.Mes == Date.ToString("MMM", culture) &&
                                                   x.Anio == Date.ToString("yyyy", culture) &&
                                                   x.Categoria == SelectedItem).ToList().Sum(x => double.Parse(x.GastosCantidad)).ToString();
            SumaGasto = ListaGastos.Where(x => x.Mes == Date.ToString("MMM", culture) &&
                                          x.Anio == Date.ToString("yyyy", culture)).ToList().Sum(x => double.Parse(x.GastosCantidad)).ToString();
            CollectionGastos = new ObservableCollection <Gastos>(ListaGastos.OrderByDescending(x => double.Parse(x.Dia)).ToList());
            instanciarPaginasService.Instanciar();
        }
Example #2
0
        public async void Delete(Gastos gastos)
        {
            var confirmacion = await dialogService.ShowMessageConfirmacion("Mensaje", "¿Desea borrar este elemento?");

            if (confirmacion)
            {
                var GastoAntiguo = ListaGastos.Find(x => x.GastosId.Equals(gastos.GastosId));
                dataService.Delete(GastoAntiguo);
                ListaGastos.Remove(GastoAntiguo);
                SumaGastoCategoria = ListaGastos.Where(x => x.Mes == Date.ToString("MMM", culture) &&
                                                       x.Anio == Date.ToString("yyyy", culture) &&
                                                       x.Categoria == SelectedItem).ToList().Sum(x => double.Parse(x.GastosCantidad)).ToString();
                SumaGasto = ListaGastos.Where(x => x.Mes == Date.ToString("MMM", culture) &&
                                              x.Anio == Date.ToString("yyyy", culture)).ToList().Sum(x => double.Parse(x.GastosCantidad)).ToString();
                CollectionGastos = new ObservableCollection <Gastos>(ListaGastos.OrderByDescending(x => double.Parse(x.Dia)).ToList());
                instanciarPaginasService.Instanciar();
            }
            else
            {
                return;
            }
        }