private async Task UpdateBackgroundProcessHistoryAsync(
            int backgroundProcessHistoryId,
            int providerCount,
            BackgroundProcessHistoryStatus historyStatus,
            string userName,
            string errorMessage = null)
        {
            var backgroundProcessHistory = await GetBackgroundProcessHistoryDataAsync(backgroundProcessHistoryId, false);

            if (backgroundProcessHistory == null)
            {
                await _functionLogRepository.CreateAsync(new FunctionLog
                {
                    ErrorMessage = $"UpdateBackgroundProcessHistoryAsync::Background Processing History not found for id {backgroundProcessHistoryId}",
                    FunctionName = nameof(ReferralEmailService),
                    RowNumber    = -1
                });

                throw new InvalidOperationException($"Cannot update non-existent background processing history for id={backgroundProcessHistoryId}");
            }

            backgroundProcessHistory.RecordCount   = providerCount;
            backgroundProcessHistory.Status        = historyStatus.ToString();
            backgroundProcessHistory.StatusMessage = errorMessage;
            backgroundProcessHistory.ModifiedBy    = userName;
            backgroundProcessHistory.ModifiedOn    = _dateTimeProvider.UtcNow();

            await _backgroundProcessHistoryRepository.UpdateWithSpecifiedColumnsOnlyAsync(backgroundProcessHistory,
                                                                                          history => history.RecordCount,
                                                                                          history => history.Status,
                                                                                          history => history.StatusMessage,
                                                                                          history => history.ModifiedBy,
                                                                                          history => history.ModifiedOn);
        }
 private async Task UpdateBackgroundProcessHistoryAsync(
     BackgroundProcessHistory backgroundProcessHistory,
     int providerCount, BackgroundProcessHistoryStatus historyStatus,
     string userName, string errorMessage = null)
 {
     backgroundProcessHistory.RecordCount   = providerCount;
     backgroundProcessHistory.Status        = historyStatus.ToString();
     backgroundProcessHistory.StatusMessage = errorMessage;
     backgroundProcessHistory.ModifiedBy    = userName;
     backgroundProcessHistory.ModifiedOn    = _dateTimeProvider.UtcNow();
     await _backgroundProcessHistoryRepository.UpdateAsync(backgroundProcessHistory);
 }