public ExpenseDetailPage(ExpenseDetailViewModel expenseDetailViewModel) { InitializeComponent(); this.viewModel = expenseDetailViewModel; BindingContext = this.viewModel; categoryPicker.ItemsSource = this.viewModel.CategoryNames; categoryPicker.SelectedItem = this.viewModel.Expense.CategoryName; }
public AddExpensePage(ExpenseViewModel expenseView) { Constants.myAdID = "ca-app-pub-6838059012127071/2589200474"; InitializeComponent(); var expenseStore = new SQLiteExpenseStore(DependencyService.Get <ISQLiteDb>()); var pageService = new PageService(); Title = (expenseView.Id == 0) ? "New Expense" : "Edit Expense"; BindingContext = new ExpenseDetailViewModel(expenseView ?? new ExpenseViewModel(), expenseStore, pageService); }
public ExpenseDetailPage() { InitializeComponent(); var expense = new Expense { ExpenseId = string.Empty, Particular = string.Empty, Amount = string.Empty }; viewModel = new ExpenseDetailViewModel(expense); BindingContext = viewModel; }
public IActionResult Edit(Guid id) { // Get the Expense from the ExpenseSystem var expense = _theExpenseSystem.GetExpense(id); // build the view model var expenseViewModel = new ExpenseDetailViewModel() { ItemId = expense.ItemId, StoreName = expense.StoreName, ItemName = expense.ItemName, Amount = expense.Amount, ExpenseDate = expense.ExpenseDate, Category = expense.Category }; // send the view model ViewBag.IsEditing = true; return(View("Form", expenseViewModel)); }
public async Task <IActionResult> Detail(int id) { string userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var expense = await _expenseDbContext.Expenses .Include(x => x.Category) .Include(x => x.ExpenseTags) .ThenInclude(et => et.Tag) .FirstOrDefaultAsync(expense => expense.Id == id && expense.ExpenseAppUserId == userId); var expenseDetail = new ExpenseDetailViewModel { Amount = expense.Amount, Description = expense.Description, Date = expense.Date, Category = expense.Category.Description, PhotoPath = expense.PhotoPath, Tags = expense.ExpenseTags.Select(item => item.Tag.Name) }; return(View(expenseDetail)); }
public IActionResult UpdateExpense(ExpenseDetailViewModel updatedExpense) { if (ModelState.IsValid) { var expense = new ExpenseDetail() { ItemId = updatedExpense.ItemId, StoreName = updatedExpense.StoreName, ItemName = updatedExpense.ItemName, Amount = updatedExpense.Amount, ExpenseDate = updatedExpense.ExpenseDate, Category = updatedExpense.Category }; _theExpenseSystem.UpdateEachExpense(expense); return(RedirectToAction("ViewExpense")); } else { ViewBag.IsEditing = true; return(View("Form", updatedExpense)); } }
public IActionResult AddExpense(ExpenseDetailViewModel expense) { expense.ItemId = Guid.NewGuid(); if (ModelState.IsValid) { var expenseToCreate = new ExpenseDetail() { ItemId = expense.ItemId, StoreName = expense.StoreName, ItemName = expense.ItemName, Amount = expense.Amount, ExpenseDate = expense.ExpenseDate, Category = expense.Category }; _theExpenseSystem.AddNewExpense(expenseToCreate); return(RedirectToAction("ViewExpense")); } else { return(View("Form", expense)); } }
public ExpenseDetailPage(ExpenseDetailViewModel viewModel) { InitializeComponent(); BindingContext = this.viewModel = viewModel; }
public ExpenseDetail(Expense expense) { BindingContext = new ExpenseDetailViewModel(expense); Title = "Expense Detail"; InitializeComponent(); }
public ExpenseDetailPage() { InitializeComponent(); BindingContext = viewModel = new ExpenseDetailViewModel(); }