Beispiel #1
0
        public void AddUrl(UrlWithWebhooks urlWithWebhooks)
        {
            List <UrlWithWebhooks> loadedUrls = GetDeserializedUrls();
            var oldRecord = loadedUrls.Find(r => r.Url == urlWithWebhooks.Url);

            if (oldRecord != null)
            {
                loadedUrls.Remove(oldRecord);
            }

            loadedUrls.Add(urlWithWebhooks);
            JsonSerializerOptions options = new JsonSerializerOptions();

            options.WriteIndented = true;
            string serializedData = JsonSerializer.Serialize(loadedUrls, options);

            using (StreamWriter sw = new StreamWriter(filePath))
            {
                sw.Write(serializedData);
            }
        }
Beispiel #2
0
        public bool IsProductDelivered(List <UrlWithWebhooks> storedUrls, List <Webhook> webhooks, string productUrl)
        {
            if (IsUrlStored(storedUrls, productUrl))
            {
                UrlWithWebhooks product = storedUrls.Find(p => p.Url == productUrl);

                if (product.Webhooks.Count != webhooks.Count)
                {
                    return(false);
                }

                foreach (Webhook wh in webhooks)
                {
                    if (product.Webhooks.Any(w => w.Hash == wh.Hash) == false)
                    {
                        return(false);
                    }
                }
                return(true);
            }
            return(false);
        }