Ejemplo n.º 1
0
        public ActionResult <Transaction> Post([FromBody] Transaction transaction)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                _transactionsRepository.Add(transaction);
                _transactionsRepository.SaveChanges();
            }
            catch (Exception ex)
            {
                return(BadRequest(_translationService.TranslateException(ex, Request.Headers)));
            }

            return(CreatedAtAction("post", transaction.Id));
        }
        public IHttpActionResult AddTransaction(Guid id, ApiModels.Transaction transaction)
        {
            var repo = new TransactionsRepository();

            if (repo.Add(_connectionString, transaction, id))
            {
                return(Ok());
            }

            return(BadRequest("Could not update account amount"));;
        }
        public async Task <ResponseDto> AddTransactions(Transactions transactions)
        {
            await transactionsRepository.Add(transactions);

            return(new ResponseDto($"Transaction was successfull."));
        }