// GET /expenses/ public ActionResult Index() { var expenseForms = _context.ExpenseForms.ToList(); var expenseForm = new ExpenseForm(); return(View(expenseForms)); }
public ActionResult SaveExpenseForm(ExpenseFormViewModel expenseForm) { if (!ModelState.IsValid) { return(View("Index")); } var _user = _userManager.FindById(User.Identity.GetUserId()); var expenseForms = _context.ExpenseForms.Where(e => e.UserId == _user.Id).ToList(); if (expenseForm.Id == 0) { var expenseFormToSave = new ExpenseForm { Name = expenseForm.Name, DateAdded = DateTime.Now, TotalCost = 0, UserId = _user.Id, User = _user }; _context.ExpenseForms.Add(expenseFormToSave); } else { var _expenseFormInDb = _context.ExpenseForms.First(e => e.Id == expenseForm.Id); _expenseFormInDb.Name = expenseForm.Name; } _context.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Update(ExpenseForm expense) { await _expenseService.Update(expense); var viewModel = new ExpenseListViewModel() { VirtualAccountId = expense.VirtualAccountId, Expenses = await _expenseService.GetAll(expense.VirtualAccountId) }; return(PartialView("_ExpenseList", viewModel)); }
public async void IsBankAccountCreatePossible() { var form = new ExpenseForm() { Amount = 20.05, Name = "Pączek", ExpenseCategoryId = 1, VirtualAccountId = 1 }; var result = await _expenseService.Create(form); Assert.NotEqual(0, result); }
public async Task <int> Create(ExpenseForm form) { try { var newEntity = _mapper.Map <DaoExpense>(form); var createdEntry = _context.Expenses.Add(newEntity); await _context.SaveChangesAsync(); return(createdEntry.Entity.Id); } catch (Exception e) { throw new RepositoryException(typeof(DaoExpense).Name, eRepositoryExceptionType.Create); } }
public override void edit(int id) { Expense Expense = (from p in db.Expense // consult where p.Id == id select p).FirstOrDefault(); ExpenseForm ExpenseViewer = new ExpenseForm(); ExpenseViewer.mainEntity = Expense; ExpenseViewer.controller = this; if (ExpenseViewer.ShowDialog() == System.Windows.Forms.DialogResult.OK) { db.SaveChanges(); } }
private void EditTransactionClicked(object sender, RoutedEventArgs e) { var transaction = this.transactions.Where(t => t.InvoiceNumber == (sender as Button).Tag.ToString()).First <Transactions>(); if (transaction != null) { if (transaction is Income) { var incomeForm = new IncomeForm(this.dbAccess, (Income)transaction); incomeForm.Show(); } else { var expenseForm = new ExpenseForm(this.dbAccess, (Expense)transaction); expenseForm.Show(); } } }
public async Task <int> Update(ExpenseForm form) { try { var updateEntity = this._mapper.Map <DaoExpenseCategory>(form); var updated = await _context.Expenses.FirstOrDefaultAsync(_ => _.Id == updateEntity.Id); _context.Entry(updated).CurrentValues.SetValues(updateEntity); await _context.SaveChangesAsync(); return(updated.Id); } catch (Exception e) { throw new RepositoryException(typeof(DaoExpense).Name, eRepositoryExceptionType.Update); } }
public override void add() { try { Expense Expense = new Expense(); // initilize entity ExpenseForm ExpenseViewer = new ExpenseForm(); ExpenseViewer.mainEntity = Expense; ExpenseViewer.controller = this; if (ExpenseViewer.ShowDialog() == System.Windows.Forms.DialogResult.OK) { db.Expense.Add(Expense); db.SaveChanges(); } } catch (System.InvalidOperationException ex) { MessageBox.Show(ex.Message); } }
private void ExpenseButtonClicked(object sender, RoutedEventArgs e) { var expenseForm = new ExpenseForm(this.dbAccess); expenseForm.Show(); }
public async Task <int> Update(ExpenseForm form) { return(await _expenseRepository.Update(form)); }
private void addExpenseToolStripMenuItem_Click(object sender, EventArgs e) { ExpenseForm expense = new ExpenseForm(); expense.Show(); }
internal static void OpenExpenseForm() { ExpenseForm ef = new ExpenseForm(); ef.Show(); }
private void Expensebutton_Click(object sender, EventArgs e) { ExpenseForm s = new ExpenseForm(); s.Show(); }