public void ValidateForCircularLoop(string pageUrl, string redirectUrl, Guid? id = null)
{
var redirects = GetAllRedirects();
if (id.HasValue && !id.Value.HasDefaultValue())
{
redirects.Where(r => r.Id == id.Value).ForEach(r =>
{
r.PageUrl = pageUrl;
r.RedirectUrl = redirectUrl;
});
}
else
{
id = Guid.NewGuid();
redirects.Add(new Redirect
{
Id = Guid.NewGuid(),
PageUrl = pageUrl,
RedirectUrl = redirectUrl
});
}
var checkedIds = new List<Guid> { id.Value };
RecursiveCircularLoop(redirects, redirectUrl, checkedIds, pageUrl, redirectUrl);
}