ปรับ api เข้ากับ โครงสร้างใหม่
This commit is contained in:
parent
8851ac6db0
commit
811fa781b4
20 changed files with 1397 additions and 73 deletions
41
.github/workflows/release.yaml
vendored
41
.github/workflows/release.yaml
vendored
|
|
@ -11,7 +11,8 @@ on:
|
|||
env:
|
||||
REGISTRY: docker.frappet.com
|
||||
IMAGE_NAME: ehr/bma-ehr-recruit-exam-service
|
||||
DEPLOY_HOST: 49.0.91.80
|
||||
DEPLOY_HOST: frappet.com
|
||||
DEPLOY_PORT: 10102
|
||||
COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-recruit-exam
|
||||
TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
|
||||
|
||||
|
|
@ -60,27 +61,27 @@ jobs:
|
|||
host: ${{env.DEPLOY_HOST}}
|
||||
username: frappet
|
||||
password: ${{ secrets.SSH_PASSWORD }}
|
||||
port: 10102
|
||||
port: ${{env.DEPLOY_PORT}}
|
||||
script: |
|
||||
cd "${{env.COMPOSE_PATH}}"
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
|
||||
- uses: snow-actions/line-notify@v1.1.0
|
||||
if: success()
|
||||
with:
|
||||
access_token: ${{ env.TOKEN_LINE }}
|
||||
message: |
|
||||
-Success✅✅✅
|
||||
Image: ${{env.IMAGE_NAME}}
|
||||
Version: ${{ github.event.inputs.IMAGE_VER }}
|
||||
By: ${{secrets.DOCKER_USER}}
|
||||
- uses: snow-actions/line-notify@v1.1.0
|
||||
if: failure()
|
||||
with:
|
||||
access_token: ${{ env.TOKEN_LINE }}
|
||||
message: |
|
||||
-Failure❌❌❌
|
||||
Image: ${{env.IMAGE_NAME}}
|
||||
Version: ${{ github.event.inputs.IMAGE_VER }}
|
||||
By: ${{secrets.DOCKER_USER}}
|
||||
# - uses: snow-actions/line-notify@v1.1.0
|
||||
# if: success()
|
||||
# with:
|
||||
# access_token: ${{ env.TOKEN_LINE }}
|
||||
# message: |
|
||||
# -Success✅✅✅
|
||||
# Image: ${{env.IMAGE_NAME}}
|
||||
# Version: ${{ github.event.inputs.IMAGE_VER }}
|
||||
# By: ${{secrets.DOCKER_USER}}
|
||||
# - uses: snow-actions/line-notify@v1.1.0
|
||||
# if: failure()
|
||||
# with:
|
||||
# access_token: ${{ env.TOKEN_LINE }}
|
||||
# message: |
|
||||
# -Failure❌❌❌
|
||||
# Image: ${{env.IMAGE_NAME}}
|
||||
# Version: ${{ github.event.inputs.IMAGE_VER }}
|
||||
# By: ${{secrets.DOCKER_USER}}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@
|
|||
<PropertyGroup Condition=" '$(RunConfiguration)' == 'https-api' " />
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AWSSDK.S3" Version="3.7.103.39" />
|
||||
<PackageReference Include="BMA.EHR.Core" Version="1.0.0" />
|
||||
<PackageReference Include="BMA.EHR.Extensions" Version="1.0.5" />
|
||||
<!-- <PackageReference Include="BMA.EHR.Core" Version="1.0.0" />
|
||||
<PackageReference Include="BMA.EHR.Extensions" Version="1.0.5" /> -->
|
||||
<PackageReference Include="BouncyCastle.NetCore" Version="1.9.0" />
|
||||
<PackageReference Include="EPPlus" Version="6.1.3" />
|
||||
<PackageReference Include="EPPlus.Interfaces" Version="6.1.1" />
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using BMA.EHR.Core;
|
||||
// using BMA.EHR.Core;
|
||||
using BMA.EHR.Recurit.Exam.Service.Response;
|
||||
using BMA.EHR.Recurit.Exam.Service.Services;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
|
@ -39,7 +39,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
|
||||
protected virtual ActionResult<ResponseObject> Success(object? result = null)
|
||||
{
|
||||
return Success(GlobalMessages.Success, result);
|
||||
return Success("สำเร็จ", result);
|
||||
}
|
||||
|
||||
protected virtual ActionResult<ResponseObject> Error(string message, string result, int statusCode = StatusCodes.Status500InternalServerError)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using Amazon.S3.Model;
|
||||
using BMA.EHR.Extensions;
|
||||
using BMA.EHR.Recurit.Exam.Service.Extensions;
|
||||
using BMA.EHR.Recurit.Exam.Service.Controllers;
|
||||
using BMA.EHR.Recurit.Exam.Service.Core;
|
||||
using BMA.EHR.Recurit.Exam.Service.Data;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using BMA.EHR.Extensions;
|
||||
using BMA.EHR.Recurit.Exam.Service.Extensions;
|
||||
using BMA.EHR.Recurit.Exam.Service.Controllers;
|
||||
using BMA.EHR.Recurit.Exam.Service.Services;
|
||||
using BMA.EHR.Recurit.Exam.Service.Data;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using BMA.EHR.Core;
|
||||
// using BMA.EHR.Core;
|
||||
using BMA.EHR.Recurit.Exam.Service.Request;
|
||||
using BMA.EHR.Recurit.Exam.Service.Response;
|
||||
using BMA.EHR.Recurit.Exam.Service.Services;
|
||||
|
|
@ -43,7 +43,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
return Success(GlobalMessages.Success, "ผ่าน");
|
||||
return Success("สำเร็จ", "ผ่าน");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using BMA.EHR.Core;
|
||||
using BMA.EHR.Extensions;
|
||||
// using BMA.EHR.Core;
|
||||
using BMA.EHR.Recurit.Exam.Service.Extensions;
|
||||
using BMA.EHR.Recurit.Exam.Service.Models;
|
||||
using BMA.EHR.Recurit.Exam.Service.Services;
|
||||
using Newtonsoft.Json;
|
||||
|
|
|
|||
13
Extensions/DataReaderExtension.cs
Normal file
13
Extensions/DataReaderExtension.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
using System.Data.Common;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Extensions
|
||||
{
|
||||
public static class DataReaderExtension
|
||||
{
|
||||
public static bool IsDbNull(this DbDataReader dataReader, string columnName)
|
||||
{
|
||||
return dataReader[columnName] == DBNull.Value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
415
Extensions/DateTimeExtension.cs
Normal file
415
Extensions/DateTimeExtension.cs
Normal file
|
|
@ -0,0 +1,415 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Extensions
|
||||
{
|
||||
public static class DateTimeExtension
|
||||
{
|
||||
private static CultureInfo _culture = new CultureInfo("th-TH");
|
||||
|
||||
#region " Methods "
|
||||
|
||||
#region " Public "
|
||||
|
||||
public static int DiffDay(this DateTime startDate, DateTime endDate)
|
||||
{
|
||||
if (endDate.Date < startDate.Date)
|
||||
{
|
||||
throw new ArgumentException("End Date must greater than start date.");
|
||||
}
|
||||
return (int)(endDate.Date - startDate.Date).TotalDays + 1;
|
||||
}
|
||||
|
||||
public static double DiffYear(this DateTime currentDate)
|
||||
{
|
||||
return (DateTime.Today - currentDate).TotalDays / 365.2425;
|
||||
}
|
||||
|
||||
public static int ToUnixTimeStamp(this DateTime value)
|
||||
{
|
||||
return (int)Math.Truncate((value.ToUniversalTime().Subtract(new DateTime(1970, 1, 1))).TotalSeconds);
|
||||
}
|
||||
|
||||
public static string ToThaiFullDate(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"วันที่ {value.Day} เดือน {value.ToString("MMMM", _culture.DateTimeFormat)} พ.ศ. {yy}";
|
||||
}
|
||||
|
||||
public static string ToThaiFullDate2(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day} {value.ToString("MMMM", _culture.DateTimeFormat)} พ.ศ. {yy}";
|
||||
}
|
||||
|
||||
public static string ToThaiFullDate3(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day} {value.ToString("MMMM", _culture.DateTimeFormat)} {yy}";
|
||||
}
|
||||
|
||||
public static string ToThaiShortDateTime(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day} {value.ToString("MMM", _culture.DateTimeFormat)} {yy} {value.ToString("HH:mm:ss")}";
|
||||
}
|
||||
|
||||
public static string ToThaiShortDate(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day} {value.ToString("MMM", _culture.DateTimeFormat)} {yy}";
|
||||
}
|
||||
|
||||
public static string ToThaiShortDate2(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day} {value.ToString("MMM", _culture.DateTimeFormat)} {yy.ToString().Right(2)}";
|
||||
}
|
||||
|
||||
public static string ToThaiDate(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day}/{value.Month}/{yy}";
|
||||
}
|
||||
|
||||
public static string ToCeDate(this DateTime value)
|
||||
{
|
||||
var yy = value.Year >= 2400 ? value.Year - 543 : value.Year;
|
||||
return $"{value.Day}/{value.Month}/{yy}";
|
||||
}
|
||||
|
||||
public static string ToThaiDateFullDigit(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day.ToString("00")}/{value.Month.ToString("00")}/{yy.ToString("00")}";
|
||||
}
|
||||
|
||||
public static string GetDay(this DateTime value)
|
||||
{
|
||||
return value.Day.ToString();
|
||||
}
|
||||
|
||||
public static string GetMonth(this DateTime value)
|
||||
{
|
||||
return value.ToString("MMMM", _culture.DateTimeFormat);
|
||||
}
|
||||
|
||||
public static string GetYear(this DateTime value)
|
||||
{
|
||||
return value.Year.ToThaiYear().ToString();
|
||||
}
|
||||
|
||||
public static string CalculateAgeStrV2(this DateTime date, int plusYear = 0, int subtractYear = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var currentDate = DateTime.Now;
|
||||
var age = currentDate - date;
|
||||
|
||||
|
||||
if (date > currentDate)
|
||||
{
|
||||
throw new ArgumentException("วันเกิดต้องไม่มากกว่าวันที่ปัจจุบัน");
|
||||
}
|
||||
|
||||
int years = currentDate.Year - date.Year;
|
||||
int months = 0;
|
||||
int days = 0;
|
||||
|
||||
if (currentDate.Month < date.Month ||
|
||||
(currentDate.Month == date.Month && currentDate.Day < date.Day))
|
||||
{
|
||||
years--;
|
||||
months = 12 - date.Month + currentDate.Month;
|
||||
|
||||
if (currentDate.Day < date.Day)
|
||||
{
|
||||
months--;
|
||||
int lastMonthDays = 0;
|
||||
if (currentDate.Month == 1)
|
||||
lastMonthDays = DateTime.DaysInMonth(currentDate.Year - 1, 12);
|
||||
else
|
||||
lastMonthDays = DateTime.DaysInMonth(currentDate.Year, currentDate.Month - 1);
|
||||
days = lastMonthDays - date.Day + currentDate.Day;
|
||||
}
|
||||
else
|
||||
{
|
||||
days = currentDate.Day - date.Day;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
months = currentDate.Month - date.Month;
|
||||
|
||||
if (currentDate.Day < date.Day)
|
||||
{
|
||||
months--;
|
||||
int lastMonthDays = 0;
|
||||
if (currentDate.Month == 1)
|
||||
lastMonthDays = DateTime.DaysInMonth(currentDate.Year - 1, 12);
|
||||
else
|
||||
lastMonthDays = DateTime.DaysInMonth(currentDate.Year, currentDate.Month - 1);
|
||||
days = lastMonthDays - date.Day + currentDate.Day;
|
||||
}
|
||||
else
|
||||
{
|
||||
days = currentDate.Day - date.Day;
|
||||
}
|
||||
}
|
||||
|
||||
//return new Age(years, months, days);
|
||||
|
||||
|
||||
//// แปลงเป็นอายุในรูปแบบวันที่
|
||||
//int years = (int)(age.Days / 365.25) + plusYear - subtractYear;
|
||||
//int months = (int)((age.Days % 365.25) / 30.436875);
|
||||
//int days = (int)((age.Days % 365.25) % 30.436875);
|
||||
|
||||
return $"{years} ปี {months} เดือน {days} วัน";
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static int CalculateAge(this DateTime date, int plusYear = 0, int subtractYear = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var currentDate = DateTime.Now;
|
||||
var age = currentDate - date;
|
||||
|
||||
// แปลงเป็นอายุในรูปแบบวันที่
|
||||
int years = (int)(age.Days / 365.25) + plusYear - subtractYear;
|
||||
|
||||
return years;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static int CalculateGovAge(this DateTime appointDate, int plusYear = 0, int subtractYear = 0)
|
||||
{
|
||||
if (DateTime.Now.Month - appointDate.Month >= 6)
|
||||
return (DateTime.Now.Year - appointDate.Year) + 1 + plusYear - subtractYear;
|
||||
else
|
||||
return (DateTime.Now.Year - appointDate.Year) + plusYear - subtractYear;
|
||||
}
|
||||
|
||||
|
||||
public static string CalculateGovAgeStr(this DateTime appointDate, int plusYear = 0, int subtractYear = 0)
|
||||
{
|
||||
var d2 = DateTime.Now;
|
||||
TimeSpan sp = d2.Subtract(appointDate);
|
||||
var alldays = sp.Days + ((plusYear - subtractYear) * 365);
|
||||
|
||||
int yy = alldays / 365;
|
||||
int mm = (alldays - (yy * 365)) / 30;
|
||||
int dd = (alldays - (yy * 365) - (mm * 30));
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.Clear();
|
||||
sb.Append(yy == 0 ? "" : $"{yy} ปี ");
|
||||
sb.Append(mm == 0 ? "" : $"{mm} เดือน ");
|
||||
sb.Append(dd == 0 ? "" : $"{dd} วัน ");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static string CalculateGovAgeInYear(this DateTime appointDate, int plusYear = 0, int subtractYear = 0)
|
||||
{
|
||||
var d2 = DateTime.Now;
|
||||
TimeSpan sp = d2.Subtract(appointDate);
|
||||
var alldays = sp.Days + ((plusYear - subtractYear) * 365);
|
||||
|
||||
int yy = alldays / 365;
|
||||
|
||||
return yy.ToString();
|
||||
}
|
||||
|
||||
public static int GetDifferenceInYears(this DateTime startDate, DateTime endDate)
|
||||
{
|
||||
int finalResult = 0;
|
||||
|
||||
const int daysInYear = 365;
|
||||
|
||||
//DateTime endDate = DateTime.Now;
|
||||
|
||||
TimeSpan timeSpan = endDate - startDate;
|
||||
|
||||
if (timeSpan.TotalDays > 365)
|
||||
{
|
||||
finalResult = (int)Math.Round((timeSpan.TotalDays / daysInYear), MidpointRounding.ToEven);
|
||||
}
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
|
||||
public static DateTime CalculateRetireDate(this DateTime birthDate)
|
||||
{
|
||||
var dd = birthDate.Day;
|
||||
var mm = birthDate.Month;
|
||||
var yy = birthDate.Year;
|
||||
|
||||
var g1 = true;
|
||||
switch (mm)
|
||||
{
|
||||
case 10: if (dd >= 2) g1 = false; break;
|
||||
case 11:
|
||||
case 12: g1 = false; break;
|
||||
}
|
||||
|
||||
if (g1)
|
||||
return new DateTime(yy + 60, 9, 30);
|
||||
else
|
||||
return new DateTime(yy + 61, 9, 30);
|
||||
}
|
||||
|
||||
public static bool IsBetween(this DateTime now, TimeSpan start, TimeSpan end)
|
||||
{
|
||||
var time = now.TimeOfDay;
|
||||
// Scenario 1: If the start time and the end time are in the same day.
|
||||
if (start <= end)
|
||||
return time >= start && time <= end;
|
||||
// Scenario 2: The start time and end time is on different days.
|
||||
return time >= start || time <= end;
|
||||
}
|
||||
|
||||
public static string CalculateBetweenDate(this DateTime startDate, DateTime endDate)
|
||||
{
|
||||
// var d2 = DateTime.Now;
|
||||
TimeSpan sp = endDate.Subtract(startDate);
|
||||
var alldays = sp.Days;
|
||||
|
||||
int yy = alldays / 365;
|
||||
int mm = (alldays - (yy * 365)) / 30;
|
||||
int dd = (alldays - (yy * 365) - (mm * 30));
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.Clear();
|
||||
sb.Append(yy == 0 ? "" : $"{yy} ปี ");
|
||||
sb.Append(mm == 0 ? "" : $"{mm} เดือน ");
|
||||
sb.Append(dd == 0 ? "" : $"{dd} วัน ");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static string CalculateBetweenDateV2(this DateTime startDate, DateTime endDate)
|
||||
{
|
||||
if (startDate == null || endDate == null)
|
||||
return "-";
|
||||
|
||||
DateTime today = endDate;
|
||||
DateTime birthDate = Convert.ToDateTime(startDate).AddDays(-1);
|
||||
int years = new DateTime(endDate.Subtract(birthDate).Ticks).Year - 1;
|
||||
DateTime pastYearDate = birthDate.AddYears(years);
|
||||
int months = 0;
|
||||
for (int i = 1; i <= 12; i++)
|
||||
{
|
||||
if (pastYearDate.AddMonths(i) == today)
|
||||
{
|
||||
months = i;
|
||||
break;
|
||||
}
|
||||
else if (pastYearDate.AddMonths(i) >= today)
|
||||
{
|
||||
months = i - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int days = today.Subtract(pastYearDate.AddMonths(months)).Days;
|
||||
if (today.Day < pastYearDate.Day)
|
||||
{
|
||||
if (System.DateTime.DaysInMonth(pastYearDate.Year, pastYearDate.Month) > System.DateTime.DaysInMonth(pastYearDate.AddMonths(months).Year, pastYearDate.AddMonths(months).Month))
|
||||
{
|
||||
days += 1;
|
||||
}
|
||||
if (System.DateTime.DaysInMonth(pastYearDate.Year, pastYearDate.Month) < System.DateTime.DaysInMonth(pastYearDate.AddMonths(months).Year, pastYearDate.AddMonths(months).Month))
|
||||
{
|
||||
days -= 1;
|
||||
}
|
||||
}
|
||||
// int Hours = Today.Subtract(PastYearDate).Hours;
|
||||
// int Minutes = Today.Subtract(PastYearDate).Minutes;
|
||||
// int Seconds = Today.Subtract(PastYearDate).Seconds;
|
||||
Console.WriteLine(today);
|
||||
Console.WriteLine(pastYearDate);
|
||||
Console.WriteLine(months);
|
||||
Console.WriteLine(pastYearDate.AddMonths(months));
|
||||
var sb = new StringBuilder();
|
||||
sb.Clear();
|
||||
sb.Append(years == 0 ? "" : $"{years} ปี ");
|
||||
sb.Append(months == 0 ? "" : $"{months} เดือน ");
|
||||
sb.Append(days == 0 ? "" : $"{days} วัน ");
|
||||
return sb.ToString();
|
||||
}
|
||||
public static CalculateBetweenDateV2ValueObj CalculateBetweenDateV2Value(this DateTime startDate, DateTime endDate)
|
||||
{
|
||||
// if (startDate == null || endDate == null)
|
||||
// return null;
|
||||
DateTime today = endDate.AddDays(1);
|
||||
DateTime birthDate = startDate;
|
||||
int years = new DateTime(endDate.Subtract(birthDate).Ticks).Year - 1;
|
||||
DateTime pastYearDate = birthDate.AddYears(years);
|
||||
int months = 0;
|
||||
for (int i = 1; i <= 12; i++)
|
||||
{
|
||||
if (pastYearDate.AddMonths(i) == today)
|
||||
{
|
||||
months = i;
|
||||
break;
|
||||
}
|
||||
else if (pastYearDate.AddMonths(i) >= today)
|
||||
{
|
||||
months = i - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int days = today.Subtract(pastYearDate.AddMonths(months)).Days;
|
||||
if (today.Day < pastYearDate.Day)
|
||||
{
|
||||
if (System.DateTime.DaysInMonth(pastYearDate.Year, pastYearDate.Month) > System.DateTime.DaysInMonth(pastYearDate.AddMonths(months).Year, pastYearDate.AddMonths(months).Month))
|
||||
{
|
||||
days += 1;
|
||||
}
|
||||
if (System.DateTime.DaysInMonth(pastYearDate.Year, pastYearDate.Month) < System.DateTime.DaysInMonth(pastYearDate.AddMonths(months).Year, pastYearDate.AddMonths(months).Month))
|
||||
{
|
||||
days -= 1;
|
||||
}
|
||||
}
|
||||
if (days >= 30)
|
||||
{
|
||||
months = months + 1;
|
||||
days = 0;
|
||||
if (months >= 12)
|
||||
{
|
||||
years = years + 1;
|
||||
months = 0;
|
||||
}
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.Clear();
|
||||
sb.Append(years == 0 ? "" : $"{years} ปี ");
|
||||
sb.Append(months == 0 ? "" : $"{months} เดือน ");
|
||||
sb.Append(days == 0 ? "" : $"{days} วัน ");
|
||||
return new CalculateBetweenDateV2ValueObj { years = years, months = months, days = days };
|
||||
}
|
||||
public class CalculateBetweenDateV2ValueObj
|
||||
{
|
||||
public int years { get; set; }
|
||||
|
||||
public int months { get; set; }
|
||||
|
||||
public int days { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
256
Extensions/DoubleExtension.cs
Normal file
256
Extensions/DoubleExtension.cs
Normal file
|
|
@ -0,0 +1,256 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Extensions
|
||||
{
|
||||
public static class DoubleExtension
|
||||
{
|
||||
#region " Fields "
|
||||
private static string[] _ones =
|
||||
{
|
||||
"zero",
|
||||
"one",
|
||||
"two",
|
||||
"three",
|
||||
"four",
|
||||
"five",
|
||||
"six",
|
||||
"seven",
|
||||
"eight",
|
||||
"nine"
|
||||
};
|
||||
|
||||
private static string[] _teens =
|
||||
{
|
||||
"ten",
|
||||
"eleven",
|
||||
"twelve",
|
||||
"thirteen",
|
||||
"fourteen",
|
||||
"fifteen",
|
||||
"sixteen",
|
||||
"seventeen",
|
||||
"eighteen",
|
||||
"nineteen"
|
||||
};
|
||||
|
||||
private static string[] _tens =
|
||||
{
|
||||
"",
|
||||
"ten",
|
||||
"twenty",
|
||||
"thirty",
|
||||
"forty",
|
||||
"fifty",
|
||||
"sixty",
|
||||
"seventy",
|
||||
"eighty",
|
||||
"ninety"
|
||||
};
|
||||
|
||||
// US Nnumbering:
|
||||
private static string[] _thousands =
|
||||
{
|
||||
"",
|
||||
"thousand",
|
||||
"million",
|
||||
"billion",
|
||||
"trillion",
|
||||
"quadrillion"
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
||||
#region " Conversion "
|
||||
|
||||
public static string ToNumericText(this double number)
|
||||
{
|
||||
return number.ToString("#,##0.00");
|
||||
}
|
||||
public static string ToNumericNoDecimalText(this double number)
|
||||
{
|
||||
return number.ToString("#,##");
|
||||
}
|
||||
|
||||
public static string ToReadText(this double value)
|
||||
{
|
||||
string digits, temp;
|
||||
bool showThousands = false;
|
||||
bool allZeros = true;
|
||||
|
||||
// Use StringBuilder to build result
|
||||
StringBuilder builder = new StringBuilder();
|
||||
// Convert integer portion of value to string
|
||||
digits = ((long)value).ToString();
|
||||
// Traverse characters in reverse order
|
||||
for (int i = digits.Length - 1; i >= 0; i--)
|
||||
{
|
||||
int ndigit = (int)(digits[i] - '0');
|
||||
int column = (digits.Length - (i + 1));
|
||||
|
||||
// Determine if ones, tens, or hundreds column
|
||||
switch (column % 3)
|
||||
{
|
||||
case 0: // Ones position
|
||||
showThousands = true;
|
||||
if (i == 0)
|
||||
{
|
||||
// First digit in number (last in loop)
|
||||
temp = String.Format("{0} ", _ones[ndigit]);
|
||||
}
|
||||
else if (digits[i - 1] == '1')
|
||||
{
|
||||
// This digit is part of "teen" value
|
||||
temp = String.Format("{0} ", _teens[ndigit]);
|
||||
// Skip tens position
|
||||
i--;
|
||||
}
|
||||
else if (ndigit != 0)
|
||||
{
|
||||
// Any non-zero digit
|
||||
temp = String.Format("{0} ", _ones[ndigit]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// This digit is zero. If digit in tens and hundreds
|
||||
// column are also zero, don't show "thousands"
|
||||
temp = String.Empty;
|
||||
// Test for non-zero digit in this grouping
|
||||
if (digits[i - 1] != '0' || (i > 1 && digits[i - 2] != '0'))
|
||||
showThousands = true;
|
||||
else
|
||||
showThousands = false;
|
||||
}
|
||||
|
||||
// Show "thousands" if non-zero in grouping
|
||||
if (showThousands)
|
||||
{
|
||||
if (column > 0)
|
||||
{
|
||||
temp = String.Format("{0}{1}{2}",
|
||||
temp,
|
||||
_thousands[column / 3],
|
||||
allZeros ? " " : ", ");
|
||||
}
|
||||
// Indicate non-zero digit encountered
|
||||
allZeros = false;
|
||||
}
|
||||
builder.Insert(0, temp);
|
||||
break;
|
||||
|
||||
case 1: // Tens column
|
||||
if (ndigit > 0)
|
||||
{
|
||||
temp = String.Format("{0}{1}",
|
||||
_tens[ndigit],
|
||||
(digits[i + 1] != '0') ? "-" : " ");
|
||||
builder.Insert(0, temp);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: // Hundreds column
|
||||
if (ndigit > 0)
|
||||
{
|
||||
temp = String.Format("{0} hundred ", _ones[ndigit]);
|
||||
builder.Insert(0, temp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Append fractional portion/cents
|
||||
double val = (value - (long)value) * 100;
|
||||
if (val > 0)
|
||||
builder.AppendFormat("and {0:00}/100", (value - (long)value) * 100);
|
||||
|
||||
// Capitalize first letter
|
||||
return String.Format("{0}{1}",
|
||||
Char.ToUpper(builder[0]),
|
||||
builder.ToString(1, builder.Length - 1));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Round "
|
||||
|
||||
public static double RoundUp(this double input)
|
||||
{
|
||||
return Math.Ceiling(input);
|
||||
}
|
||||
|
||||
public static double RoundDown(this double input)
|
||||
{
|
||||
return Math.Floor(input);
|
||||
}
|
||||
|
||||
|
||||
public static double RoundUpStang(this double input)
|
||||
{
|
||||
string temp = "";
|
||||
temp = input.ToNumericText();
|
||||
string[] floating = temp.Split('.');
|
||||
if (double.Parse(floating[1]) == 0)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
if (double.Parse(floating[1]) >= 1 && double.Parse(floating[1]) <= 24)
|
||||
{
|
||||
return (double.Parse(floating[0])) + 0.25;
|
||||
}
|
||||
else if (double.Parse(floating[1]) >= 26 && double.Parse(floating[1]) <= 49)
|
||||
{
|
||||
return (double.Parse(floating[0])) + 0.5;
|
||||
}
|
||||
else if (double.Parse(floating[1]) >= 51 && double.Parse(floating[1]) <= 74)
|
||||
{
|
||||
return (double.Parse(floating[0])) + 0.75;
|
||||
}
|
||||
else if (double.Parse(floating[1]) >= 76 && double.Parse(floating[1]) <= 99)
|
||||
{
|
||||
return (double.Parse(floating[0])) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
public static double RoundDownStang(this double input)
|
||||
{
|
||||
string temp = "";
|
||||
temp = input.ToNumericText();
|
||||
string[] floating = temp.Split('.');
|
||||
if (double.Parse(floating[1]) == 0)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
if (double.Parse(floating[1]) >= 1 && double.Parse(floating[1]) <= 24)
|
||||
{
|
||||
return Math.Floor(input);
|
||||
}
|
||||
else if (double.Parse(floating[1]) >= 26 && double.Parse(floating[1]) <= 49)
|
||||
{
|
||||
return (double.Parse(floating[0])) + 0.25;
|
||||
}
|
||||
else if (double.Parse(floating[1]) >= 51 && double.Parse(floating[1]) <= 74)
|
||||
{
|
||||
return (double.Parse(floating[0])) + 0.5;
|
||||
}
|
||||
else if (double.Parse(floating[1]) >= 76 && double.Parse(floating[1]) <= 99)
|
||||
{
|
||||
return (double.Parse(floating[0])) + 0.75;
|
||||
}
|
||||
else
|
||||
{
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
74
Extensions/IntegerExtension.cs
Normal file
74
Extensions/IntegerExtension.cs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
using System.Text;
|
||||
// using GreatFriends.ThaiBahtText;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Extensions
|
||||
{
|
||||
public static class IntegerExtension
|
||||
{
|
||||
// public static string ToThaiBahtText(this int value, bool appendBahtOnly)
|
||||
// {
|
||||
// var decValue = (decimal)value;
|
||||
|
||||
// return decValue.ThaiBahtText(appendBahtOnly: appendBahtOnly);
|
||||
// }
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
public static string ToThaiNumber(this string value)
|
||||
{
|
||||
string arabicNumbers = "0123456789";
|
||||
string thaiNumbers = "๐๑๒๓๔๕๖๗๘๙";
|
||||
StringBuilder result = new StringBuilder();
|
||||
foreach (char digit in value)
|
||||
{
|
||||
int index = arabicNumbers.IndexOf(digit);
|
||||
if (index >= 0)
|
||||
{
|
||||
result.Append(thaiNumbers[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Append(digit);
|
||||
}
|
||||
}
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Extensions/ListExtension.cs
Normal file
37
Extensions/ListExtension.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Extensions
|
||||
{
|
||||
public static class ListExtension
|
||||
{
|
||||
#region " Methods "
|
||||
|
||||
#region " Convert "
|
||||
|
||||
public static DataTable ToDataTable<T>(this List<T> list)
|
||||
{
|
||||
PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(T));
|
||||
DataTable table = new DataTable();
|
||||
for (int i = 0; i < props.Count; i++)
|
||||
{
|
||||
PropertyDescriptor prop = props[i];
|
||||
table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
|
||||
}
|
||||
object[] values = new object[props.Count];
|
||||
foreach (T item in list)
|
||||
{
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
values[i] = props[i].GetValue(item) ?? DBNull.Value; table.Rows.Add(values);
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
51
Extensions/ObjectExtension.cs
Normal file
51
Extensions/ObjectExtension.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Extensions
|
||||
{
|
||||
public static class ObjectExtension
|
||||
{
|
||||
public static bool DeepCompare(this object obj, object another)
|
||||
{
|
||||
if (ReferenceEquals(obj, another)) return true;
|
||||
if ((obj == null) || (another == null)) return false;
|
||||
//Compare two object's class, return false if they are difference
|
||||
if (obj.GetType() != another.GetType()) return false;
|
||||
|
||||
var result = true;
|
||||
//Get all properties of obj
|
||||
//And compare each other
|
||||
foreach (var property in obj.GetType().GetProperties())
|
||||
{
|
||||
var objValue = property.GetValue(obj);
|
||||
var anotherValue = property.GetValue(another);
|
||||
if (!objValue.Equals(anotherValue)) result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool Compare(this object obj, object another)
|
||||
{
|
||||
if (ReferenceEquals(obj, another)) return true;
|
||||
if ((obj == null) || (another == null)) return false;
|
||||
if (obj.GetType() != another.GetType()) return false;
|
||||
|
||||
//properties: int, double, DateTime, etc, not class
|
||||
if (!obj.GetType().IsClass) return obj.Equals(another);
|
||||
|
||||
var result = true;
|
||||
foreach (var property in obj.GetType().GetProperties())
|
||||
{
|
||||
var objValue = property.GetValue(obj);
|
||||
var anotherValue = property.GetValue(another);
|
||||
//Recursion
|
||||
if (!objValue.DeepCompare(anotherValue)) result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Extensions/StreamExtension.cs
Normal file
29
Extensions/StreamExtension.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Extensions
|
||||
{
|
||||
public static class StreamExtension
|
||||
{
|
||||
#region " Methods "
|
||||
|
||||
#region " Public "
|
||||
|
||||
public static string ToBase64(this MemoryStream stream)
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
byte[] bytes;
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
stream.CopyTo(memoryStream);
|
||||
bytes = memoryStream.ToArray();
|
||||
}
|
||||
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
301
Extensions/StringExtension.cs
Normal file
301
Extensions/StringExtension.cs
Normal file
|
|
@ -0,0 +1,301 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Extensions
|
||||
{
|
||||
public enum DateTimeFormat
|
||||
{
|
||||
Dmy,
|
||||
Mdy,
|
||||
Ymd
|
||||
}
|
||||
|
||||
public static partial class StringExtension
|
||||
{
|
||||
#region " Methods "
|
||||
|
||||
#region " Utilities "
|
||||
|
||||
public static string Format(this string input, int digit)
|
||||
{
|
||||
var fmt = $"D{digit}";
|
||||
return input.ToInteger().ToString(fmt);
|
||||
|
||||
}
|
||||
|
||||
public static string RemoveComma(this string value)
|
||||
{
|
||||
string ret;
|
||||
if (value.Contains(","))
|
||||
{
|
||||
ret = value.Replace(",", "");
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value != "")
|
||||
{
|
||||
return value;
|
||||
}
|
||||
else
|
||||
return "0.00";
|
||||
}
|
||||
}
|
||||
|
||||
public static string RemoveSpace(this string value)
|
||||
{
|
||||
string ret;
|
||||
if (value.Contains(","))
|
||||
{
|
||||
ret = value.Replace(" ", "");
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value != "")
|
||||
{
|
||||
return value;
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static string Left(this string input, int length)
|
||||
{
|
||||
if (length > 0 && input.Length >= length)
|
||||
{
|
||||
return input.Substring(0, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
public static string Right(this string input, int length)
|
||||
{
|
||||
if (length > 0 && input.Length >= length)
|
||||
{
|
||||
return input.Substring(input.Length - length, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Validation "
|
||||
|
||||
public static bool IsDateTime(this string input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var d = Convert.ToDateTime(input);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsUrl(this string input)
|
||||
{
|
||||
if (input.Trim() != "")
|
||||
{
|
||||
if ((input.Left(7).ToLower() != "http://") || (input.Left(8).ToLower() != "https://"))
|
||||
{
|
||||
input = "http://" + input;
|
||||
}
|
||||
Regex reg = new Regex("http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?");
|
||||
return reg.Match(input).Success;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this instance is email.
|
||||
/// </summary>
|
||||
/// <param name="input">The input.</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsEmail(this string input)
|
||||
{
|
||||
if (input.Trim() != "")
|
||||
{
|
||||
Regex reg = new Regex("\\w+([-+.\']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
|
||||
return reg.Match(input).Success;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this instance is numeric.
|
||||
/// </summary>
|
||||
/// <param name="input">The input.</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsNumeric(this string input)
|
||||
{
|
||||
if (input.Length > 0)
|
||||
{
|
||||
double tempDouble = (double)(NumberStyles.Number);
|
||||
return double.TryParse(input, out tempDouble);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static string IsNull(this string input, string value)
|
||||
{
|
||||
if (input == null)
|
||||
return value;
|
||||
else
|
||||
return input;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Conversion "
|
||||
|
||||
public static DateTime ToDateTime(this string input, DateTimeFormat format, string seperator = "/")
|
||||
{
|
||||
try
|
||||
{
|
||||
var dd = input.Split(seperator);
|
||||
switch (format)
|
||||
{
|
||||
case DateTimeFormat.Dmy:
|
||||
return new DateTime(dd[2].ToInteger().ToCeYear(), dd[1].ToInteger(), dd[0].ToInteger());
|
||||
case DateTimeFormat.Mdy:
|
||||
return new DateTime(dd[2].ToInteger().ToCeYear(), dd[0].ToInteger(), dd[1].ToInteger());
|
||||
case DateTimeFormat.Ymd:
|
||||
return new DateTime(dd[0].ToInteger().ToCeYear(), dd[1].ToInteger(), dd[2].ToInteger());
|
||||
default:
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static string ValueOrBlank(this string input)
|
||||
{
|
||||
if (input == null) return "";
|
||||
|
||||
if (input == "0")
|
||||
return "";
|
||||
else
|
||||
return input;
|
||||
}
|
||||
|
||||
public static MemoryStream ToMemoryStream(this string base64String)
|
||||
{
|
||||
if (base64String == null || base64String == String.Empty) return null;
|
||||
|
||||
var bytes = Convert.FromBase64String(base64String);
|
||||
var stream = new MemoryStream(bytes);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
public static double ToDouble(this string input)
|
||||
{
|
||||
if (input == null) return 0.0;
|
||||
|
||||
if (input == "") return 0.0;
|
||||
|
||||
double ret = 0.0;
|
||||
input = input.RemoveComma();
|
||||
if (input.IsNumeric())
|
||||
{
|
||||
ret = double.Parse(input);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static float ToFloat(this string input)
|
||||
{
|
||||
if (input == null) return 0F;
|
||||
|
||||
if (input == "") return 0F;
|
||||
|
||||
float ret = 0F;
|
||||
input = input.RemoveComma();
|
||||
if (input.IsNumeric())
|
||||
{
|
||||
ret = float.Parse(input);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int ToInteger(this string input)
|
||||
{
|
||||
if (input == null) return 0;
|
||||
|
||||
if (input == "") return 0;
|
||||
|
||||
int ret = 0;
|
||||
input = input.RemoveComma();
|
||||
int.TryParse(input, out ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static string ToBlank(this string value)
|
||||
{
|
||||
if (value == "0")
|
||||
return "";
|
||||
else
|
||||
return value;
|
||||
}
|
||||
|
||||
public static DateTime ToCeDateTime(this string date)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime dddd;
|
||||
if (!DateTime.TryParse(date, out dddd))
|
||||
return DateTime.MinValue;
|
||||
|
||||
|
||||
if (date == "01/01/0001")
|
||||
return Convert.ToDateTime(date);
|
||||
|
||||
string[] dd = date.Split('/');
|
||||
|
||||
int yy = 0;
|
||||
if (dd[2].Length == 2)
|
||||
yy = dd[2].Left(2).ToInteger() + 2500;
|
||||
else
|
||||
yy = dd[2].Left(4).ToInteger();
|
||||
if (yy >= 2400) yy -= 543;
|
||||
DateTime birthdate = new DateTime(yy, dd[1].ToInteger(), dd[0].ToInteger());
|
||||
return birthdate;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
127
Extensions/TimeSpanExtension.cs
Normal file
127
Extensions/TimeSpanExtension.cs
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
using System;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Extensions
|
||||
{
|
||||
public static class TimeSpanExtension
|
||||
{
|
||||
#region " To days "
|
||||
|
||||
public static double ConvertMillisecondsToDays(this double milliseconds)
|
||||
{
|
||||
return TimeSpan.FromMilliseconds(milliseconds).TotalDays;
|
||||
}
|
||||
|
||||
public static double ConvertSecondsToDays(this double seconds)
|
||||
{
|
||||
return TimeSpan.FromSeconds(seconds).TotalDays;
|
||||
}
|
||||
|
||||
public static double ConvertMinutesToDays(this double minutes)
|
||||
{
|
||||
return TimeSpan.FromMinutes(minutes).TotalDays;
|
||||
}
|
||||
|
||||
public static double ConvertHoursToDays(this double hours)
|
||||
{
|
||||
return TimeSpan.FromHours(hours).TotalDays;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " To hours "
|
||||
|
||||
public static double ConvertMillisecondsToHours(this double milliseconds)
|
||||
{
|
||||
return TimeSpan.FromMilliseconds(milliseconds).TotalHours;
|
||||
}
|
||||
|
||||
public static double ConvertSecondsToHours(this double seconds)
|
||||
{
|
||||
return TimeSpan.FromSeconds(seconds).TotalHours;
|
||||
}
|
||||
|
||||
public static double ConvertMinutesToHours(this double minutes)
|
||||
{
|
||||
return TimeSpan.FromMinutes(minutes).TotalHours;
|
||||
}
|
||||
|
||||
public static double ConvertDaysToHours(this double days)
|
||||
{
|
||||
return TimeSpan.FromHours(days).TotalHours;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " To minutes "
|
||||
|
||||
public static double ConvertMillisecondsToMinutes(this double milliseconds)
|
||||
{
|
||||
return TimeSpan.FromMilliseconds(milliseconds).TotalMinutes;
|
||||
}
|
||||
|
||||
public static double ConvertSecondsToMinutes(this double seconds)
|
||||
{
|
||||
return TimeSpan.FromSeconds(seconds).TotalMinutes;
|
||||
}
|
||||
|
||||
public static double ConvertHoursToMinutes(this double hours)
|
||||
{
|
||||
return TimeSpan.FromHours(hours).TotalMinutes;
|
||||
}
|
||||
|
||||
public static double ConvertDaysToMinutes(this double days)
|
||||
{
|
||||
return TimeSpan.FromDays(days).TotalMinutes;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " To seconds "
|
||||
|
||||
public static double ConvertMillisecondsToSeconds(this double milliseconds)
|
||||
{
|
||||
return TimeSpan.FromMilliseconds(milliseconds).TotalSeconds;
|
||||
}
|
||||
|
||||
public static double ConvertMinutesToSeconds(this double minutes)
|
||||
{
|
||||
return TimeSpan.FromMinutes(minutes).TotalSeconds;
|
||||
}
|
||||
|
||||
public static double ConvertHoursToSeconds(this double hours)
|
||||
{
|
||||
return TimeSpan.FromHours(hours).TotalSeconds;
|
||||
}
|
||||
|
||||
public static double ConvertDaysToSeconds(this double days)
|
||||
{
|
||||
return TimeSpan.FromDays(days).TotalSeconds;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " To milliseconds "
|
||||
|
||||
public static double ConvertSecondsToMilliseconds(this double seconds)
|
||||
{
|
||||
return TimeSpan.FromSeconds(seconds).TotalMilliseconds;
|
||||
}
|
||||
|
||||
public static double ConvertMinutesToMilliseconds(this double minutes)
|
||||
{
|
||||
return TimeSpan.FromMinutes(minutes).TotalMilliseconds;
|
||||
}
|
||||
|
||||
public static double ConvertHoursToMilliseconds(this double hours)
|
||||
{
|
||||
return TimeSpan.FromHours(hours).TotalMilliseconds;
|
||||
}
|
||||
|
||||
public static double ConvertDaysToMilliseconds(this double days)
|
||||
{
|
||||
return TimeSpan.FromDays(days).TotalMilliseconds;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -11,13 +11,13 @@ namespace BMA.EHR.Domain.Models.Placement
|
|||
[Comment("Id บรรจุ")]
|
||||
public Placement? Placement { get; set; }
|
||||
[Comment("Id คำนำหน้า")]
|
||||
public Prefix? Prefix { get; set; }
|
||||
public string? Prefix { get; set; }
|
||||
[Comment("ชื่อ")]
|
||||
public string? Firstname { get; set; }
|
||||
[Comment("นามสกุล")]
|
||||
public string? Lastname { get; set; }
|
||||
[Comment("Id เพศ")]
|
||||
public Gender? Gender { get; set; }
|
||||
public string? Gender { get; set; }
|
||||
|
||||
[Comment("Id ตำแหน่งที่สอบได้")]
|
||||
public PositionPath? PositionCandidate { get; set; }
|
||||
|
|
@ -62,11 +62,11 @@ namespace BMA.EHR.Domain.Models.Placement
|
|||
public DateTime? DateOfBirth { get; set; }
|
||||
|
||||
[Comment("Id สถานภาพ")]
|
||||
public Relationship? Relationship { get; set; }
|
||||
public string? Relationship { get; set; }
|
||||
// [Comment("Id กลุ่มเลือด")]
|
||||
// public BloodGroup? BloodGroup { get; set; }
|
||||
[Comment("Id ศาสนา")]
|
||||
public Religion? Religion { get; set; }
|
||||
public string? Religion { get; set; }
|
||||
|
||||
[MaxLength(200), Comment("อีเมล")]
|
||||
public string? Email { get; set; }
|
||||
|
|
@ -75,10 +75,10 @@ namespace BMA.EHR.Domain.Models.Placement
|
|||
public string? CitizenId { get; set; }
|
||||
|
||||
[Comment("Id เขตที่ออกบัตรประชาชน")]
|
||||
public District? CitizenDistrict { get; set; }
|
||||
public string? CitizenDistrictId { get; set; }
|
||||
|
||||
[Comment("Id จังหวัดที่ออกบัตรประชาชน")]
|
||||
public Province? CitizenProvince { get; set; }
|
||||
public string? CitizenProvinceId { get; set; }
|
||||
|
||||
[Comment("วันที่ออกบัตร")]
|
||||
public DateTime? CitizenDate { get; set; }
|
||||
|
|
@ -96,13 +96,13 @@ namespace BMA.EHR.Domain.Models.Placement
|
|||
public string? RegistAddress { get; set; }
|
||||
|
||||
[Comment("Id จังหวัดที่อยู่ตามทะเบียนบ้าน")]
|
||||
public Province? RegistProvince { get; set; }
|
||||
public string? RegistProvinceId { get; set; }
|
||||
|
||||
[Comment("Id อำเภอที่อยู่ตามทะเบียนบ้าน")]
|
||||
public District? RegistDistrict { get; set; }
|
||||
public string? RegistDistrictId { get; set; }
|
||||
|
||||
[Comment("Id ตำบลที่อยู่ตามทะเบียนบ้าน")]
|
||||
public SubDistrict? RegistSubDistrict { get; set; }
|
||||
public string? RegistSubDistrictId { get; set; }
|
||||
|
||||
[MaxLength(10), Comment("รหัสไปรษณีย์ที่อยู่ตามทะเบียนบ้าน")]
|
||||
public string? RegistZipCode { get; set; }
|
||||
|
|
@ -114,13 +114,13 @@ namespace BMA.EHR.Domain.Models.Placement
|
|||
public string? CurrentAddress { get; set; }
|
||||
|
||||
[Comment("Id จังหวัดที่อยู่ปัจจุบัน")]
|
||||
public Province? CurrentProvince { get; set; }
|
||||
public string? CurrentProvinceId { get; set; }
|
||||
|
||||
[Comment("Id อำเภอที่อยู่ปัจจุบัน")]
|
||||
public District? CurrentDistrict { get; set; }
|
||||
public string? CurrentDistrictId { get; set; }
|
||||
|
||||
[Comment("Id ตำบลที่อยู่ปัจจุบัน")]
|
||||
public SubDistrict? CurrentSubDistrict { get; set; }
|
||||
public string? CurrentSubDistrictId { get; set; }
|
||||
|
||||
[MaxLength(10), Comment("รหัสไปรษณีย์ที่อยู่ปัจจุบัน")]
|
||||
public string? CurrentZipCode { get; set; }
|
||||
|
|
@ -129,7 +129,7 @@ namespace BMA.EHR.Domain.Models.Placement
|
|||
public bool? Marry { get; set; }
|
||||
|
||||
[Comment("Id คำนำหน้าชื่อคู่สมรส")]
|
||||
public Prefix? MarryPrefix { get; set; }
|
||||
public string? MarryPrefix { get; set; }
|
||||
|
||||
[MaxLength(100), Comment("ชื่อจริงคู่สมรส")]
|
||||
public string? MarryFirstName { get; set; }
|
||||
|
|
@ -144,7 +144,7 @@ namespace BMA.EHR.Domain.Models.Placement
|
|||
public string? MarryNationality { get; set; }
|
||||
|
||||
[Comment("Id คำนำหน้าชื่อบิดา")]
|
||||
public Prefix? FatherPrefix { get; set; }
|
||||
public string? FatherPrefix { get; set; }
|
||||
|
||||
[MaxLength(100), Comment("ชื่อจริงบิดา")]
|
||||
public string? FatherFirstName { get; set; }
|
||||
|
|
@ -159,7 +159,7 @@ namespace BMA.EHR.Domain.Models.Placement
|
|||
public string? FatherNationality { get; set; }
|
||||
|
||||
[Comment("Id คำนำหน้าชื่อมารดา")]
|
||||
public Prefix? MotherPrefix { get; set; }
|
||||
public string? MotherPrefix { get; set; }
|
||||
|
||||
[MaxLength(100), Comment("ชื่อจริงมารดา")]
|
||||
public string? MotherFirstName { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System.Security.Claims;
|
||||
using System.Text.Json;
|
||||
using BMA.EHR.Extensions;
|
||||
using BMA.EHR.Recurit.Exam.Service.Extensions;
|
||||
using BMA.EHR.Recurit.Exam.Service.Core;
|
||||
using BMA.EHR.Recurit.Exam.Service.Data;
|
||||
using BMA.EHR.Recurit.Exam.Service.Models;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System.Security.Claims;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Extensions;
|
||||
using BMA.EHR.Recurit.Exam.Service.Extensions;
|
||||
using BMA.EHR.Recurit.Exam.Service.Core;
|
||||
using BMA.EHR.Recurit.Exam.Service.Data;
|
||||
using BMA.EHR.Recurit.Exam.Service.Models;
|
||||
|
|
@ -664,7 +664,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
EditorCondition = exam.EditorCondition,
|
||||
EditorConfirm = exam.EditorConfirm,
|
||||
Position = candidatePosition == null ? false : true,
|
||||
CanRegister = exam.RegisterStartDate == null || exam.RegisterEndDate == null ? true :DateOnly.FromDateTime(exam.RegisterStartDate.Value) <= DateOnly.FromDateTime(DateTime.Now) && DateOnly.FromDateTime(exam.RegisterEndDate.Value) >= DateOnly.FromDateTime(DateTime.Now),
|
||||
CanRegister = exam.RegisterStartDate == null || exam.RegisterEndDate == null ? true : DateOnly.FromDateTime(exam.RegisterStartDate.Value) <= DateOnly.FromDateTime(DateTime.Now) && DateOnly.FromDateTime(exam.RegisterEndDate.Value) >= DateOnly.FromDateTime(DateTime.Now),
|
||||
RegisterEndDate = exam.RegisterEndDate,
|
||||
RegisterStartDate = exam.RegisterStartDate,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using System.Security.Claims;
|
||||
using System.Text.Json;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Extensions;
|
||||
using BMA.EHR.Recurit.Exam.Service.Extensions;
|
||||
using BMA.EHR.Recurit.Exam.Service.Core;
|
||||
using BMA.EHR.Recurit.Exam.Service.Data;
|
||||
using BMA.EHR.Recurit.Exam.Service.Models;
|
||||
|
|
@ -2100,48 +2100,61 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
var profile = await _contextMetadata.Profiles
|
||||
.Include(x => x.Salaries)
|
||||
.FirstOrDefaultAsync(p => p.CitizenId == candidate.CitizenId);
|
||||
var Prefix = await _contextMetadata.Prefixes.Where(x => x.Id == candidate.PrefixId).FirstOrDefaultAsync() == null ? null : await _contextMetadata.Prefixes.Where(x => x.Id == candidate.PrefixId).FirstOrDefaultAsync();
|
||||
var Religion = await _contextMetadata.Religions.Where(x => x.Id == candidate.ReligionId).FirstOrDefaultAsync() == null ? null : await _contextMetadata.Prefixes.Where(x => x.Id == candidate.ReligionId).FirstOrDefaultAsync();
|
||||
var CitizenDistrict = await _contextMetadata.Districts.Where(x => x.Id == candidate.CitizenDistrictId).FirstOrDefaultAsync() == null ? null : await _contextMetadata.Prefixes.Where(x => x.Id == candidate.CitizenDistrictId).FirstOrDefaultAsync();
|
||||
var CitizenProvince = await _contextMetadata.Provinces.Where(x => x.Id == candidate.CitizenProvinceId).FirstOrDefaultAsync() == null ? null : await _contextMetadata.Prefixes.Where(x => x.Id == candidate.CitizenProvinceId).FirstOrDefaultAsync();
|
||||
var RegistProvince = await _contextMetadata.Provinces.Where(x => x.Id == candidate.RegistProvinceId).FirstOrDefaultAsync() == null ? null : await _contextMetadata.Prefixes.Where(x => x.Id == candidate.RegistProvinceId).FirstOrDefaultAsync();
|
||||
var RegistDistrict = await _contextMetadata.Districts.Where(x => x.Id == candidate.RegistDistrictId).FirstOrDefaultAsync() == null ? null : await _contextMetadata.Prefixes.Where(x => x.Id == candidate.RegistDistrictId).FirstOrDefaultAsync();
|
||||
var RegistSubDistrict = await _contextMetadata.SubDistricts.Where(x => x.Id == candidate.RegistSubDistrictId).FirstOrDefaultAsync() == null ? null : await _contextMetadata.Prefixes.Where(x => x.Id == candidate.RegistSubDistrictId).FirstOrDefaultAsync();
|
||||
var CurrentProvince = await _contextMetadata.Provinces.Where(x => x.Id == candidate.CurrentProvinceId).FirstOrDefaultAsync() == null ? null : await _contextMetadata.Prefixes.Where(x => x.Id == candidate.CurrentProvinceId).FirstOrDefaultAsync();
|
||||
var CurrentDistrict = await _contextMetadata.Districts.Where(x => x.Id == candidate.CurrentDistrictId).FirstOrDefaultAsync() == null ? null : await _contextMetadata.Prefixes.Where(x => x.Id == candidate.CurrentDistrictId).FirstOrDefaultAsync();
|
||||
var CurrentSubDistrict = await _contextMetadata.SubDistricts.Where(x => x.Id == candidate.CurrentSubDistrictId).FirstOrDefaultAsync() == null ? null : await _contextMetadata.Prefixes.Where(x => x.Id == candidate.CurrentSubDistrictId).FirstOrDefaultAsync();
|
||||
var MarryPrefix = await _contextMetadata.Prefixes.Where(x => x.Id == candidate.MarryPrefixId).FirstOrDefaultAsync() == null ? null : await _contextMetadata.Prefixes.Where(x => x.Id == candidate.MarryPrefixId).FirstOrDefaultAsync();
|
||||
var FatherPrefix = await _contextMetadata.Prefixes.Where(x => x.Id == candidate.FatherPrefixId).FirstOrDefaultAsync() == null ? null : await _contextMetadata.Prefixes.Where(x => x.Id == candidate.FatherPrefixId).FirstOrDefaultAsync();
|
||||
var MotherPrefix = await _contextMetadata.Prefixes.Where(x => x.Id == candidate.MotherPrefixId).FirstOrDefaultAsync() == null ? null : await _contextMetadata.Prefixes.Where(x => x.Id == candidate.MotherPrefixId).FirstOrDefaultAsync();
|
||||
var placementProfile = new PlacementProfile
|
||||
{
|
||||
Placement = placement,
|
||||
PositionCandidate = await _contextMetadata.PositionPaths.FirstOrDefaultAsync(x => x.Id == (candidate.PositionExam == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : candidate.PositionExam.PositionId)),
|
||||
Prefix = await _contextMetadata.Prefixes.FirstOrDefaultAsync(x => x.Id == candidate.PrefixId),
|
||||
Prefix = Prefix == null ? null : Prefix.Name,
|
||||
ProfileImg = candidate.ProfileImg,
|
||||
Firstname = candidate.FirstName,
|
||||
Lastname = candidate.LastName,
|
||||
Nationality = candidate.Nationality,
|
||||
DateOfBirth = candidate.DateOfBirth,
|
||||
Religion = await _contextMetadata.Religions.FirstOrDefaultAsync(x => x.Id == candidate.ReligionId),
|
||||
Religion = Religion == null ? null : Religion.Name,
|
||||
Email = candidate.Email,
|
||||
CitizenId = candidate.CitizenId,
|
||||
CitizenDistrict = await _contextMetadata.Districts.FirstOrDefaultAsync(x => x.Id == candidate.CitizenDistrictId),
|
||||
CitizenProvince = await _contextMetadata.Provinces.FirstOrDefaultAsync(x => x.Id == candidate.CitizenProvinceId),
|
||||
CitizenDistrictId = CitizenDistrict == null ? null : CitizenDistrict.Id.ToString(),
|
||||
CitizenProvinceId = CitizenProvince == null ? null : CitizenProvince.Id.ToString(),
|
||||
CitizenDate = candidate.CitizenDate,
|
||||
Telephone = candidate.Telephone,
|
||||
MobilePhone = candidate.MobilePhone,
|
||||
Knowledge = candidate.Knowledge,
|
||||
RegistAddress = candidate.RegistAddress,
|
||||
RegistProvince = await _contextMetadata.Provinces.FirstOrDefaultAsync(x => x.Id == candidate.RegistProvinceId),
|
||||
RegistDistrict = await _contextMetadata.Districts.FirstOrDefaultAsync(x => x.Id == candidate.RegistDistrictId),
|
||||
RegistSubDistrict = await _contextMetadata.SubDistricts.FirstOrDefaultAsync(x => x.Id == candidate.RegistSubDistrictId),
|
||||
RegistProvinceId = RegistProvince == null ? null : RegistProvince.Id.ToString(),
|
||||
RegistDistrictId = RegistDistrict == null ? null : RegistDistrict.Id.ToString(),
|
||||
RegistSubDistrictId = RegistSubDistrict == null ? null : RegistSubDistrict.Id.ToString(),
|
||||
RegistZipCode = candidate.RegistZipCode,
|
||||
RegistSame = candidate.RegistSame,
|
||||
CurrentAddress = candidate.CurrentAddress,
|
||||
CurrentProvince = await _contextMetadata.Provinces.FirstOrDefaultAsync(x => x.Id == candidate.CurrentProvinceId),
|
||||
CurrentDistrict = await _contextMetadata.Districts.FirstOrDefaultAsync(x => x.Id == candidate.CurrentDistrictId),
|
||||
CurrentSubDistrict = await _contextMetadata.SubDistricts.FirstOrDefaultAsync(x => x.Id == candidate.CurrentSubDistrictId),
|
||||
CurrentProvinceId = CurrentProvince == null ? null : CurrentProvince.Id.ToString(),
|
||||
CurrentDistrictId = CurrentDistrict == null ? null : CurrentDistrict.Id.ToString(),
|
||||
CurrentSubDistrictId = CurrentSubDistrict == null ? null : CurrentSubDistrict.Id.ToString(),
|
||||
CurrentZipCode = candidate.CurrentZipCode,
|
||||
Marry = candidate.Marry,
|
||||
MarryPrefix = await _contextMetadata.Prefixes.FirstOrDefaultAsync(x => x.Id == candidate.MarryPrefixId),
|
||||
MarryPrefix = MarryPrefix == null ? null : MarryPrefix.Name,
|
||||
MarryFirstName = candidate.MarryFirstName,
|
||||
MarryLastName = candidate.MarryLastName,
|
||||
MarryOccupation = candidate.MarryOccupation,
|
||||
MarryNationality = candidate.MarryNationality,
|
||||
FatherPrefix = await _contextMetadata.Prefixes.FirstOrDefaultAsync(x => x.Id == candidate.FatherPrefixId),
|
||||
FatherPrefix = FatherPrefix == null ? null : FatherPrefix.Name,
|
||||
FatherFirstName = candidate.FatherFirstName,
|
||||
FatherLastName = candidate.FatherLastName,
|
||||
FatherOccupation = candidate.FatherOccupation,
|
||||
FatherNationality = candidate.FatherNationality,
|
||||
MotherPrefix = await _contextMetadata.Prefixes.FirstOrDefaultAsync(x => x.Id == candidate.MotherPrefixId),
|
||||
MotherPrefix = MotherPrefix == null ? null : MotherPrefix.Name,
|
||||
MotherFirstName = candidate.MotherFirstName,
|
||||
MotherLastName = candidate.MotherLastName,
|
||||
MotherOccupation = candidate.MotherOccupation,
|
||||
|
|
@ -2261,37 +2274,44 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
var profile = await _contextMetadata.Profiles
|
||||
.Include(x => x.Salaries)
|
||||
.FirstOrDefaultAsync(p => p.CitizenId == candidate.CitizenId);
|
||||
var CitizenProvince = await _contextMetadata.Provinces.Where(x => x.Name == candidate.CitizenCardIssuer).FirstOrDefaultAsync();
|
||||
var RegistProvince = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.Provinces.Where(x => x.Name == candidate.Addresses.FirstOrDefault().Province).FirstOrDefaultAsync();
|
||||
var RegistDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.Districts.Where(x => x.Name == candidate.Addresses.FirstOrDefault().District).FirstOrDefaultAsync();
|
||||
var RegistSubDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.SubDistricts.Where(x => x.Name == candidate.Addresses.FirstOrDefault().Amphur).FirstOrDefaultAsync();
|
||||
var CurrentProvince = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.Provinces.Where(x => x.Name == candidate.Addresses.FirstOrDefault().Province1).FirstOrDefaultAsync();
|
||||
var CurrentDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.Districts.Where(x => x.Name == candidate.Addresses.FirstOrDefault().District1).FirstOrDefaultAsync();
|
||||
var CurrentSubDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.SubDistricts.Where(x => x.Name == candidate.Addresses.FirstOrDefault().Amphur1).FirstOrDefaultAsync();
|
||||
var placementProfile = new PlacementProfile
|
||||
{
|
||||
Placement = placement,
|
||||
PositionCandidate = await _contextMetadata.PositionPaths.FirstOrDefaultAsync(x => x.Name == candidate.PositionName),
|
||||
Prefix = await _contextMetadata.Prefixes.FirstOrDefaultAsync(x => x.Name == candidate.Prefix),
|
||||
Prefix = candidate.Prefix,
|
||||
Firstname = candidate.FirstName,
|
||||
Lastname = candidate.LastName,
|
||||
Gender = await _contextMetadata.Genders.FirstOrDefaultAsync(x => x.Name == candidate.Gendor),
|
||||
Gender = candidate.Gendor,
|
||||
Nationality = candidate.National,
|
||||
Race = candidate.Race,
|
||||
Religion = await _contextMetadata.Religions.FirstOrDefaultAsync(x => x.Name == candidate.Religion),
|
||||
Religion = candidate.Religion,
|
||||
DateOfBirth = candidate.DateOfBirth,
|
||||
Relationship = await _contextMetadata.Relationships.FirstOrDefaultAsync(x => x.Name == candidate.Marry),
|
||||
Relationship = candidate.Marry,
|
||||
// Email = candidate.Email,
|
||||
CitizenId = candidate.CitizenId,
|
||||
// CitizenDistrict = await _contextMetadata.Districts.FirstOrDefaultAsync(x => x.Id == candidate.CitizenDistrictId),
|
||||
CitizenProvince = await _contextMetadata.Provinces.FirstOrDefaultAsync(x => x.Name == candidate.CitizenCardIssuer),
|
||||
CitizenProvinceId = CitizenProvince == null ? null : CitizenProvince.Id.ToString(),
|
||||
CitizenDate = candidate.CitizenCardExpireDate,
|
||||
Telephone = candidate.Addresses.FirstOrDefault() == null ? null : candidate.Addresses.FirstOrDefault().Telephone,
|
||||
MobilePhone = candidate.Addresses.FirstOrDefault() == null ? null : candidate.Addresses.FirstOrDefault().Mobile,
|
||||
// Knowledge = candidate.Knowledge,
|
||||
RegistAddress = $"{Address}{Moo}{Soi}{Road}",
|
||||
RegistProvince = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.Provinces.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().Province),
|
||||
RegistDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.Districts.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().District),
|
||||
RegistSubDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.SubDistricts.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().Amphur),
|
||||
RegistProvinceId = RegistProvince == null ? null : RegistProvince.Id.ToString(),
|
||||
RegistDistrictId = RegistDistrict == null ? null : RegistDistrict.Id.ToString(),
|
||||
RegistSubDistrictId = RegistSubDistrict == null ? null : RegistSubDistrict.Id.ToString(),
|
||||
RegistZipCode = candidate.Addresses.FirstOrDefault() == null ? null : candidate.Addresses.FirstOrDefault().ZipCode,
|
||||
RegistSame = false,
|
||||
CurrentAddress = $"{Address1}{Moo1}{Soi1}{Road1}",
|
||||
CurrentProvince = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.Provinces.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().Province1),
|
||||
CurrentDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.Districts.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().District1),
|
||||
CurrentSubDistrict = candidate.Addresses.FirstOrDefault() == null ? null : await _contextMetadata.SubDistricts.FirstOrDefaultAsync(x => x.Name == candidate.Addresses.FirstOrDefault().Amphur1),
|
||||
CurrentProvinceId = CurrentProvince == null ? null : CurrentProvince.Id.ToString(),
|
||||
CurrentDistrictId = CurrentDistrict == null ? null : CurrentDistrict.Id.ToString(),
|
||||
CurrentSubDistrictId = CurrentSubDistrict == null ? null : CurrentSubDistrict.Id.ToString(),
|
||||
CurrentZipCode = candidate.Addresses.FirstOrDefault() == null ? null : candidate.Addresses.FirstOrDefault().ZipCode1,
|
||||
Marry = candidate.Marry.Contains("สมรส"),
|
||||
// MarryPrefix = await _contextMetadata.Prefixes.FirstOrDefaultAsync(x => x.Id == candidate.MarryPrefixId),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue