예제 #1
0
        public async Task <IActionResult> CreateExpense([FromBody] Expense expense)
        {
            if (await _expenseRepository.Create(expense))
            {
                return(Ok());
            }

            return(BadRequest());
        }
예제 #2
0
        public IActionResult Create(Expense expense)
        {
            expenseRepo.Create(expense);

            var project = projectRepo.GetById(expense.ProjectId);

            project.ProjectTotalExpenses = expenseRepo.ExpenseTotal(project);
            expenseRepo.Save();
            return(RedirectToAction("Create"));
        }
예제 #3
0
        public void SaveExpense(Expense expense)
        {
            Expense dbExpense = GetExpense(expense.Id);

            if (dbExpense == null)
            {
                _expenseRepository.Create(expense);
            }
            else
            {
                _expenseRepository.Update(expense);
            }
        }
예제 #4
0
        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);
        }
예제 #5
0
        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));
        }
예제 #6
0
 public Expense Create(Expense expense)
 {
     return(expensesRepository.Create(expense));
 }
예제 #7
0
 public void Execute(Guid userId, string description, long priceWithoutTax, long priceIncludingTax)
 {
     _repository.Create(new Expense(Guid.NewGuid(), userId, description, priceWithoutTax, priceIncludingTax));
 }
예제 #8
0
 public void Create(ExpenseDTO expenseDTO)
 {
     expenseRepository.Create(expense_dtoToModel(expenseDTO));
 }
예제 #9
0
 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));
        }