คำนวนอายุการทำงาน(ยังไม่เสร็จ)
This commit is contained in:
parent
bf111fab00
commit
eb308cfeee
4 changed files with 363 additions and 274 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System.Reflection.Metadata;
|
||||
using System.Text;
|
||||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Responses;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
|
|
@ -12,6 +13,7 @@ using Microsoft.AspNetCore.Http;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using static BMA.EHR.Domain.Extensions.DateTimeExtension;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.Reports
|
||||
{
|
||||
|
|
@ -49,6 +51,37 @@ namespace BMA.EHR.Application.Repositories.Reports
|
|||
#region ใบสมัครสอบ
|
||||
public async Task<dynamic> GetExamCandidateAsync(Guid id)
|
||||
{
|
||||
var careers = await _dbExamContext.Set<Career>()
|
||||
.AsQueryable()
|
||||
.Where(x => x.Candidate.Id == id)
|
||||
.ToListAsync();
|
||||
var yearDiff = 0;
|
||||
var monthDiff = 0;
|
||||
var dayDiff = 0;
|
||||
var sb = new StringBuilder();
|
||||
foreach (var career in careers)
|
||||
{
|
||||
var rangeObj = career.DurationStart.CalculateBetweenDateV2Value(career.DurationEnd);
|
||||
yearDiff = yearDiff + rangeObj.years;
|
||||
monthDiff = monthDiff + rangeObj.months;
|
||||
dayDiff = dayDiff + rangeObj.days;
|
||||
if (dayDiff >= 30)
|
||||
{
|
||||
monthDiff = monthDiff + (int)(dayDiff / 30);
|
||||
dayDiff = dayDiff % 30;
|
||||
}
|
||||
if (monthDiff >= 12)
|
||||
{
|
||||
yearDiff = yearDiff + (int)(monthDiff / 12);
|
||||
monthDiff = monthDiff % 12;
|
||||
}
|
||||
sb.Clear();
|
||||
sb.Append(yearDiff == 0 ? "" : $"{yearDiff} ปี ");
|
||||
sb.Append(monthDiff == 0 ? "" : $"{monthDiff} เดือน ");
|
||||
sb.Append(dayDiff == 0 ? "" : $"{dayDiff} วัน ");
|
||||
sb.ToString();
|
||||
}
|
||||
|
||||
var data = await _dbExamContext.Set<Candidate>().AsQueryable()
|
||||
.Where(x => x.Id == id)
|
||||
.Select(p => new
|
||||
|
|
@ -85,6 +118,7 @@ namespace BMA.EHR.Application.Repositories.Reports
|
|||
OccupationOrg = p.OccupationOrg,
|
||||
OccupationTelephone = p.OccupationTelephone,
|
||||
|
||||
CareersTotal = sb,
|
||||
Careers = p.Careers.Select(y => new
|
||||
{
|
||||
Position = y.Position,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue