private bool AddExpenseControl(DateTime endDate, string value)
        {
            using (var expenseControlRepository = new ExpenseControlRepository())
            {
                try
                {
                    expenseControlRepository.Add(new ExpenseControl()
                    {
                        Title      = Title,
                        BeginYear  = DateTime.Now.Year,
                        BeginMonth = DateTime.Now.Month,
                        BeginDay   = DateTime.Now.Day,
                        EndYear    = endDate.Year,
                        EndMonth   = endDate.Month,
                        EndDay     = endDate.Day,
                        TotalValue = value
                    });

                    return(true);
                }
                catch (Exception error)
                {
                    return(false);
                }
            }
        }
 private void GetExpenseControl(int expenseControlId)
 {
     using (var expenseControlRepository = new ExpenseControlRepository())
     {
         ExpenseControl = expenseControlRepository.GetById(expenseControlId, true);
     }
 }
Пример #3
0
        private void GetDates()
        {
            ExpenseYearMonths?.Clear();

            using (var expenseControlRepository = new ExpenseControlRepository())
            {
                ExpenseYearMonths = new ObservableCollection <string>(expenseControlRepository.GetAllYearAndMonths());
            }
        }
Пример #4
0
        private void GetCurrentExpenses()
        {
            CurrentExpenseControl?.Clear();

            using (var expenseControlRepository = new ExpenseControlRepository())
            {
                GetCurrentDate(out int year, out int month);
                CurrentExpenseControl = new ObservableCollection <ExpenseControl>(expenseControlRepository.GetByDate(year, month));
            }

            if (CurrentExpenseControl.Count > 0)
            {
                IsVisible = true;
            }
            else
            {
                IsVisible = false;
            }
        }
Пример #5
0
        private async void RemoveTappedExpenseControl(ExpenseControl expenseControl)
        {
            bool task = await ShowDialog("Remover", "Confirmar exclusão de item?");

            if (task)
            {
                using (var expenseControlRepository = new ExpenseControlRepository())
                {
                    int id = expenseControlRepository.Remove(expenseControl);
                    if (id > 0)
                    {
                        GetCurrentExpenses();
                        Toast("Item removido com sucesso");
                    }
                    else
                    {
                        Toast("Não foi possível remover o item");
                    }
                }
            }
        }
        private bool UpdateExpenseControl(DateTime endDate, string value)
        {
            using (var expenseControlRepository = new ExpenseControlRepository())
            {
                try
                {
                    expenseControl.TotalValue = value;
                    expenseControl.EndYear    = endDate.Year;
                    expenseControl.EndMonth   = endDate.Month;
                    expenseControl.EndDay     = endDate.Day;
                    expenseControl.Title      = Title;

                    expenseControlRepository.Update(expenseControl);
                    expenseControl = expenseControlRepository.GetById(expenseControl.ExpenseControlId, true);
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
        }