18 lines
487 B
C#
18 lines
487 B
C#
using System.IO;
|
|
|
|
namespace RentalApp.Helpers;
|
|
|
|
public static class LockHelper
|
|
{
|
|
private static readonly string Path = "lock.txt";
|
|
|
|
public static void SetLock(DateTime until)
|
|
=> File.WriteAllText(Path, until.ToString("o"));
|
|
|
|
public static DateTime? GetLock()
|
|
=> File.Exists(Path) && DateTime.TryParse(File.ReadAllText(Path), out var dt)
|
|
? dt : null;
|
|
|
|
public static bool IsLocked()
|
|
=> GetLock() is DateTime dt && dt > DateTime.Now;
|
|
} |