public async Task UpdateCaseForm(int id, CaseFormForUpdateDto caseFormForUpdate) { var existingCaseForm = await _caseFormRepo.GetByIdAsync(id); if (existingCaseForm == null) { // TODO: Global exception handling can take care of the call to logger... I can remove these lines to logger once global exception handling is added in _logger.LogWarning(LoggingEvents.UpdateItemNotFound, "Case form {Id} NOT FOUND", id); throw new ApplicationException($"Case form with id {id} does not exist."); } // Map any updated field values in the dto back to the entity _mapper.Map(caseFormForUpdate, existingCaseForm); await _caseFormRepo.UpdateAsync(existingCaseForm); _logger.LogInformation(LoggingEvents.UpdateItem, "Case form {Id} Updated", existingCaseForm.Id); }
public async Task <IActionResult> Put(int id, CaseFormForUpdateDto caseForm) { await _caseFormService.UpdateCaseForm(id, caseForm); return(Ok()); }