public async Task UpdateItem(TransactionRetentiveDTO transactionRetentiveDTO) { var transactionRetentive = _mapper.Map <TransactionRetentive>(transactionRetentiveDTO); _dbContext.TransactionRetentives.Update(transactionRetentive); await _dbContext.SaveChangesAsync(); }
public async Task <ActionResult> PostTransactionRetentive(TransactionRetentiveDTO transactionRetentiveDTO) { try { await _service.InsertItem(transactionRetentiveDTO); return(CreatedAtAction("GetTransactionRetentive", new { id = transactionRetentiveDTO.TransactionRetentiveId }, transactionRetentiveDTO)); } catch (Exception ex) { Log.LogError($"Chyba při ukládání do databáze: {ex.InnerException}"); return(NotFound()); } }
public async Task <IActionResult> PutTransactionRetentive(int id, TransactionRetentiveDTO transactionRetentiveDTO) { if (id != transactionRetentiveDTO.TransactionRetentiveId) { Log.LogError($"Chyba!!! Záznam s tímto Id nebyl nalezen."); return(BadRequest()); } try { await _service.UpdateItem(transactionRetentiveDTO); return(CreatedAtAction("GetTransactionRetentive", new { id = transactionRetentiveDTO.TransactionRetentiveId }, id)); } catch (Exception ex) { Log.LogError($"Chyba při ukládání do databáze: {ex.InnerException}"); return(NotFound()); } }