public async Task <ActionResult> Close(int id) { try { bool result = await _pollRepository.ClosePollAsync(id); if (result) { _logger.LogInformation(LoggingEvents.ClosePoll, "Poll {id} status set to closed", id); return(new NoContentResult()); } else { return(StatusCode(500, "Error occurred updating the database")); } } catch (PollNotFoundException e) { ApiStatusMessage a = ApiStatusMessage.CreateFromException(e); return(BadRequest(a)); } catch (Exception e) { _logger.LogError(LoggingEvents.ClosePoll, "Error updating poll status to closed {id}: Exception {ex}", id, e.Message); return(StatusCode(500, e.Message)); } }