Exemplo n.º 1
0
        public async Task <IActionResult> Create(ExpensesJsonModel expensesJson)
        {
            if (expensesJson == null)
            {
                return(BadRequest());
            }
            var expensesCategory = await _expensesCategoryRepository.GetItemByName(expensesJson.Category);

            var expenses = _mapper.Map <ExpensesJsonModel, Expenses>(expensesJson);

            expenses.Date = DateTime.Now;

            await _expensesRepository.Create(expenses, expensesJson.CashAccount_Id);

            await _expensesRepository.CreateComunication(
                await _expensesRepository.GetItemByDate(expenses.Date), expensesCategory);

            return(Ok());
        }