hrms-api-backend/BMA.EHR.Domain/Extensions/IntegerExtension.cs
Suphonchai Phoonsawat 89de09d213 จัดระเบียบ Code ใหม่ และเพิ่ม Extension Method
implement GenericRepository Class ใหม่
2023-06-26 10:15:50 +07:00

44 lines
No EOL
1.4 KiB
C#

namespace BMA.EHR.Domain.Extensions
{
public static class IntegerExtension
{
public static string ToThaiMonth(this int value)
{
switch (value)
{
case 1: return "มกราคม";
case 2: return "กุมภาพันธ์";
case 3: return "มีนาคม";
case 4: return "เมษายน";
case 5: return "พฤษภาคม";
case 6: return "มิถุนายน";
case 7: return "กรกฎาคม";
case 8: return "สิงหาคม";
case 9: return "กันยายน";
case 10: return "ตุลาคม";
case 11: return "พฤศจิกายน";
case 12: return "ธันวาคม";
default: return "";
}
}
public static int ToThaiYear(this int value)
{
if (value < 2400)
return value + 543;
else return value;
}
public static int ToCeYear(this int value)
{
if (value >= 2400)
return value - 543;
else return value;
}
public static string ToNumericText(this int number)
{
return number.ToString("#,##0");
}
}
}