/// <summary> /// Alter the upvote value for an upload. /// </summary> /// <param name="votevalue">The value going to be added to the current downvote value.</param> /// <param name="uploadId">Id of upload used for searching.</param> /// <param name="failurecount">Current number of times operation has failed.</param> /// <param name="username">Username of person requesting operation for logging.</param> /// <param name="ipAddress">IP address of system requesting operation for logging.</param> /// <returns>A boolean for the successful completion of the operation. </returns> public async Task <bool> EditDownvotesonUpload(int votevalue, int uploadId, int failurecount, string username, string ipAddress) { try { bool result = await _uploadService.IncrementDownvotesonUpload(votevalue, uploadId).ConfigureAwait(false); _ = _loggingManager.LogAsync(DateTime.UtcNow.ToString(Constants.LoggingFormatString), Constants.DownvoteOperation + "/" + uploadId, username, ipAddress).ConfigureAwait(false); return(result); } catch (Exception e) { _ = _loggingManager.LogAsync(DateTime.UtcNow.ToString(Constants.LoggingFormatString), Constants.DownvoteOperation + "/" + uploadId, username, ipAddress).ConfigureAwait(false); failurecount += 1; if (failurecount >= Constants.LoggingRetriesAmount) { throw e; } else { return(await EditDownvotesonUpload(votevalue, uploadId, failurecount, username, ipAddress).ConfigureAwait(false)); } } }