public async Task <IActionResult> CreateExpense([FromBody] Expense expense) { if (await _expenseRepository.Create(expense)) { return(Ok()); } return(BadRequest()); }
public IActionResult Create(Expense expense) { expenseRepo.Create(expense); var project = projectRepo.GetById(expense.ProjectId); project.ProjectTotalExpenses = expenseRepo.ExpenseTotal(project); expenseRepo.Save(); return(RedirectToAction("Create")); }
public void SaveExpense(Expense expense) { Expense dbExpense = GetExpense(expense.Id); if (dbExpense == null) { _expenseRepository.Create(expense); } else { _expenseRepository.Update(expense); } }
public void CreateExpense(ExpenseDetails expenseDetails) { var Expense = Mapper.Map <Expense>(expenseDetails); var movement = new Movement(expenseDetails); var strategy = ContextMovementStrategy.GetMovementStrategy(movement, _bankAccountRepository, _historicMovementRepository, _incomeRepository, _atmWithdrawRepository); strategy.Debit(); if (movement.TargetIncomeId.HasValue) { Expense.GeneratedIncomeId = movement.TargetIncomeId.Value; } _ExpenseRepository.Create(Expense); }
public Task <bool> Handle(RegisterNewExpenseCommand command) { var owner = _accountantRepository.Get(command.Owner); if (owner == null) { AddNotification("correntista", "Correntista não localizado"); return(Task.FromResult(false)); } var bankAccount = owner.GetAccount(command.Account); if (bankAccount == null) { AddNotification("conta-corrente", "Conta corrente não localizada"); return(Task.FromResult(false)); } var entity = new Expense( Guid.NewGuid(), bankAccount, new Description(command.Description), _favoredRepository.Get(command.Favored), new Money(command.Value) ); AddNotifications(entity); if (Invalid) { return(Task.FromResult(false)); } _expenseRepository.Create(entity); _uow.Commit(); return(Task.FromResult(true)); }
public Expense Create(Expense expense) { return(expensesRepository.Create(expense)); }
public void Execute(Guid userId, string description, long priceWithoutTax, long priceIncludingTax) { _repository.Create(new Expense(Guid.NewGuid(), userId, description, priceWithoutTax, priceIncludingTax)); }
public void Create(ExpenseDTO expenseDTO) { expenseRepository.Create(expense_dtoToModel(expenseDTO)); }
public async Task <int> Create(ExpenseForm form) { return(await _expenseRepository.Create(form)); }
public async Task <ActionResult> Create([FromForm] ExpenseDto expenseDto) { var result = await _repo.Create(expenseDto); return(Ok(result)); }