38 lines
890 B
C#
38 lines
890 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace TIAMWebApp.Shared.Application.Utility
|
|
{
|
|
public class PageHistoryState
|
|
{
|
|
private readonly List<string> _previousPages = [];
|
|
|
|
public PageHistoryState()
|
|
{ }
|
|
|
|
public void AddPageToHistory(string pageUrl)
|
|
{
|
|
if (_previousPages.Count > 0 && _previousPages[^1] == pageUrl) return;
|
|
|
|
_previousPages.Add(pageUrl);
|
|
}
|
|
|
|
public string GetGoBackPage()
|
|
{
|
|
if (_previousPages.Count == 0) return string.Empty;
|
|
|
|
_previousPages.RemoveAt(_previousPages.Count - 1);
|
|
|
|
return _previousPages.Count > 0 ? _previousPages[^1] : string.Empty;
|
|
}
|
|
|
|
public bool CanGoBack()
|
|
{
|
|
return _previousPages.Count > 1;
|
|
}
|
|
}
|
|
}
|