public IActionResult Update([FromBody] UpdatePromptDto promptDto) { UpdatePromptResponseDto responseDto = null; try { if (_httpContextAccessor.GetCurrentUserId() != promptDto.AuthorId) { throw new UnauthorizedAccessException("You are not authorized to update the specified prompt."); } var prompt = _promptService.UpdatePrompt(promptDto.PromptId, promptDto.AuthorId, promptDto.Title, promptDto.Body); responseDto = _mapper.Map <UpdatePromptResponseDto>(prompt); } catch (Exception ex) { Console.WriteLine($"Encountered exception while attempting to update prompt. Message: {ex.Message}"); Console.WriteLine(ex.StackTrace); return(BadRequest(new ErrorResponseDto(ex))); } return(Ok(responseDto)); }