Exemplo n.º 1
0
        private async Task UpdateDatabaseForRecipient(
            IGrouping <Diver, Notification> pendingNotificationsForRecipient,
            Diver recipient,
            Func <Task> saver)
        {
            if (pendingNotificationsForRecipient == null)
            {
                throw new ArgumentNullException(nameof(pendingNotificationsForRecipient));
            }
            if (recipient == null)
            {
                throw new ArgumentNullException(nameof(recipient));
            }

            try
            {
                logger.LogTrace($"Updating database records for {pendingNotificationsForRecipient.Key} ...");

                recipient.MarkNotificationChecked();
                await saver();

                logger.LogTrace($"Database updated for {pendingNotificationsForRecipient.Key}");
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Error updating database for {pendingNotificationsForRecipient.Key}");
            }
        }