public async Task <IActionResult> AddTransaction(TransactionForAddDto transactionForAddDto) { var transaction = _mapper.Map <ProjectTransaction> (transactionForAddDto); _repo.Add(transaction); if (await _repo.SaveAll()) { return(NoContent()); } throw new Exception("Adding Transaction failed on save"); }
public async Task <IActionResult> EditTransaction(TransactionForAddDto transactionForAddDto) { var transaction = await _repo.GetTransaction(transactionForAddDto.Id); _mapper.Map(transactionForAddDto, transaction); if (!await _repo.SaveAll()) { throw new Exception($"Updating failed on save"); } return(NoContent()); }