64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
using System;
|
|
using System.Threading;
|
|
using Kreta.Enums.ManualEnums;
|
|
|
|
namespace Kreta.BusinessLogic.Helpers
|
|
{
|
|
public static class LicenceHelper
|
|
{
|
|
private static DateTime LicenceLejaratiDatum(string licenceDatum)
|
|
{
|
|
return Convert.ToDateTime(licenceDatum);
|
|
}
|
|
|
|
public static LicenceTipusaEnum LicenceLejaratAllapota(string licenceDatum)
|
|
{
|
|
DateTime datum = LicenceLejaratiDatum(licenceDatum);
|
|
var now = DateTime.Now;
|
|
|
|
if (datum < now.AddYears(-1))
|
|
{
|
|
return LicenceTipusaEnum.EgyEveLejart;
|
|
}
|
|
|
|
if (datum < now.AddMonths(-3))
|
|
{
|
|
return LicenceTipusaEnum.NegyedEveLejart;
|
|
}
|
|
|
|
if (datum < now.AddMonths(-1))
|
|
{
|
|
return LicenceTipusaEnum.EgyHonapjaLejart;
|
|
}
|
|
|
|
if (datum < now)
|
|
{
|
|
return LicenceTipusaEnum.Lejart;
|
|
}
|
|
|
|
return LicenceTipusaEnum.Aktiv;
|
|
}
|
|
|
|
private static int LicenceWaitTime(string licenceDatum)
|
|
{
|
|
var allapot = LicenceLejaratAllapota(licenceDatum);
|
|
switch (allapot)
|
|
{
|
|
case LicenceTipusaEnum.EgyEveLejart:
|
|
return 30;
|
|
case LicenceTipusaEnum.NegyedEveLejart:
|
|
return 10;
|
|
case LicenceTipusaEnum.EgyHonapjaLejart:
|
|
return 3;
|
|
case LicenceTipusaEnum.Lejart:
|
|
return 0;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public static void LicenceWait(string licenceDatum)
|
|
{
|
|
Thread.Sleep(1000 * LicenceWaitTime(licenceDatum));
|
|
}
|
|
}
|
|
}
|