public override void OnNavigatedTo(INavigationParameters parameters) { if (parameters.ContainsKey("expenseControl")) { _expenseControl = parameters["expenseControl"] as ExpenseControl; } }
private void NavigateToCurrentExpense(ExpenseControl expenseControl) { var parameters = new NavigationParameters(); parameters.Add("expenseControlId", expenseControl.ExpenseControlId); Navigate <ExpenseControlDetailsViewModel>(parameters); }
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); } } }
public override void OnNavigatedTo(INavigationParameters parameters) { if (parameters.ContainsKey("isEdit") && (bool)parameters["isEdit"]) { isEditing = true; expenseControl = (ExpenseControl)parameters["expenseControl"]; CurrentDate = expenseControl.BeginDateFormatted; PageTitle = EditExpenseControl; SaveButtonName = "Salvar"; Value = expenseControl.TotalValue; Title = expenseControl.Title; SelectedDate = new DateTime(expenseControl.EndYear, expenseControl.EndMonth, expenseControl.EndDay); RegisterCommand.RaiseCanExecuteChanged(); } else { SelectedDate = DateTime.Now.AddDays(2); PageTitle = NewExpenseControl; SaveButtonName = "Cadastrar"; CurrentDate = DateTime.Now.ToShortDateString(); } }