/// <summary>
        /// Persists the specified payload queue.
        /// </summary>
        /// <param name="payloadQueue">The payload queue.</param>
        private void Persist(PayloadQueue payloadQueue)
        {
            var items = payloadQueue.GetItemsToPersist();

            if (items == null || items.Length == 0)
            {
                return;
            }

            string endPoint    = payloadQueue.Logger.Config.EndPoint;
            string accessToken = payloadQueue.AccessTokenQueuesMetadata.AccessToken;

            Destination destination = this._storeContext.Destinations.SingleOrDefault(d =>
                                                                                      d.Endpoint == endPoint &&
                                                                                      d.AccessToken == accessToken
                                                                                      );

            if (destination == null)
            {
                destination = new Destination()
                {
                    Endpoint = endPoint, AccessToken = accessToken,
                };
                this._storeContext.Destinations.Add(destination);
            }

            foreach (var item in items)
            {
                PayloadRecord payloadRecord = this.BuildPayloadRecord(item, payloadQueue);
                if (payloadRecord != null)
                {
                    destination.PayloadRecords.Add(payloadRecord);
                }
            }

            try
            {
                this._storeContext.SaveChanges();
            }
            catch (System.Exception ex)
            {
                RollbarErrorUtility.Report(
                    payloadQueue.Logger,
                    items.Select(i => i.GetPayload()),
                    InternalRollbarError.PersistentStoreContextError,
                    "While attempting to save persistent store context...",
                    ex,
                    null
                    );
            }

            foreach (var item in items)
            {
                item.Signal?.Release();
            }
        }
        /// <summary>
        /// Persists the specified payload queue.
        /// </summary>
        /// <param name="payloadQueue">The payload queue.</param>
        private void Persist(PayloadQueue payloadQueue)
        {
            if (!payloadQueue.Logger.Config.EnableLocalPayloadStore)
            {
                return;
            }

            var items = payloadQueue.GetItemsToPersist();

            if (items == null || items.Length == 0)
            {
                return;
            }

            string endPoint    = payloadQueue.Logger.Config.EndPoint;
            string accessToken = payloadQueue.AccessTokenQueuesMetadata.AccessToken;

            var payloads = new List <IPayloadRecord>();

            foreach (var item in items)
            {
                payloads.Add(this.BuildPayloadRecord(item, payloadQueue));
            }

            try
            {
                this._storeRepository.SavePayloads(endPoint, accessToken, payloads);
            }
            catch (System.Exception ex)
            {
                RollbarErrorUtility.Report(
                    payloadQueue.Logger,
                    items.Select(i => i.GetPayload()),
                    InternalRollbarError.PersistentStoreContextError,
                    "While attempting to save persistent store context...",
                    ex,
                    null
                    );
            }

            foreach (var item in items)
            {
                item.Signal?.Release();
            }
        }