Merge branch 'develop' into work
This commit is contained in:
commit
9c610407f4
272 changed files with 3435 additions and 163 deletions
|
|
@ -0,0 +1,92 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Domain.Models.Commands.Core;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.Commands
|
||||
{
|
||||
public class CommandReportRepository : GenericRepository<Guid, Command>
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly IApplicationDBContext _dbContext;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly OrganizationCommonRepository _organizationCommonRepository;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destuctor "
|
||||
|
||||
public CommandReportRepository(IApplicationDBContext dbContext,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
OrganizationCommonRepository organizationCommonRepository,
|
||||
UserProfileRepository userProfileRepository) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_organizationCommonRepository = organizationCommonRepository;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Properties "
|
||||
|
||||
protected Guid UserOrganizationId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
||||
public async Task<List<dynamic>> GetCommandType01AttachmentAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var raw_data = await _dbContext.Set<CommandReceiver>()
|
||||
.Include(c => c.Command)
|
||||
.Where(c => c.Command.Id == id)
|
||||
.ToListAsync();
|
||||
if (raw_data == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
}
|
||||
|
||||
var ret = new List<dynamic>();
|
||||
|
||||
foreach (var c in raw_data)
|
||||
{
|
||||
ret.Add(new
|
||||
{
|
||||
FullName = $"{c.Prefix}{c.FirstName} {c.LastName}",
|
||||
PositionName = ""
|
||||
});
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -7,19 +7,59 @@ namespace BMA.EHR.Application.Repositories
|
|||
{
|
||||
public class PlacementRepository : GenericRepository<Guid, Placement>
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly IApplicationDBContext _dbContext;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public PlacementRepository(IApplicationDBContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
||||
public async Task<List<Placement>> GetCompetitivePlacementAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _dbContext.Set<Placement>()
|
||||
.Include(p => p.PlacementType)
|
||||
.Where(p => p.PlacementType.Name == "สอบแข่งขัน")
|
||||
.ToListAsync();
|
||||
|
||||
return data;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<Placement>> GetQualifyingPlacementAsync()
|
||||
{
|
||||
var data = await _dbContext.Set<Placement>()
|
||||
.Include(p => p.PlacementType)
|
||||
.Where(p => p.PlacementType.Name != "สอบแข่งขัน")
|
||||
.ToListAsync();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Placement>> FindByNameAsync(string name)
|
||||
{
|
||||
var data = await _dbContext.Set<Placement>().Where(x => x.Name == name).ToListAsync();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.Reports
|
||||
{
|
||||
|
|
@ -16,45 +11,115 @@ namespace BMA.EHR.Application.Repositories.Reports
|
|||
#region " Fields "
|
||||
|
||||
private readonly IApplicationDBContext _dbContext;
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public RetireReportRepository(IApplicationDBContext dbContext)
|
||||
public RetireReportRepository(IApplicationDBContext dbContext, IWebHostEnvironment hostEnvironment)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_hostingEnvironment = hostEnvironment;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
||||
public async Task<List<RetirementPeriod>> GetListRetirePeriodAsync()
|
||||
//public async Task<List<RetirementPeriod>> GetListRetirePeriodAsync(Guid Id)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// // 1. query
|
||||
// //var data = await _dbContext.Set<RetirementPeriod>()
|
||||
// // .Include(x => x.RetirementProfiles)
|
||||
// // .ThenInclude(x => x.Profile)
|
||||
// // .ToListAsync();
|
||||
|
||||
// // 2. data not found throw exception
|
||||
|
||||
// // 3. Load Report File
|
||||
|
||||
// //return data;
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// throw;
|
||||
// }
|
||||
//}
|
||||
|
||||
public async Task<dynamic> GetProfileRetirementdAsync(Guid retireId)
|
||||
{
|
||||
try
|
||||
var retire = await _dbContext.Set<RetirementPeriod>()
|
||||
.Include(x => x.RetirementProfiles)
|
||||
.FirstOrDefaultAsync(x => x.Id == retireId);
|
||||
if (retire == null)
|
||||
{
|
||||
// 1. query
|
||||
var data = await _dbContext.Set<RetirementPeriod>()
|
||||
.Include(x => x.RetirementPeriodHistorys)
|
||||
.Include(x => x.RetirementProfiles)
|
||||
.ThenInclude(x => x.Profile)
|
||||
.ToListAsync();
|
||||
var retireHistorys = await _dbContext.Set<RetirementPeriodHistory>().AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == retireId);
|
||||
if (retireHistorys == null)
|
||||
return null;
|
||||
|
||||
// 2. data not found throw exception
|
||||
|
||||
|
||||
// 3. Load Report File
|
||||
|
||||
|
||||
|
||||
return data;
|
||||
var profile_retireHistory = await _dbContext.Set<RetirementProfile>()
|
||||
.Where(x => x.RetirementPeriod == retire)
|
||||
.OrderBy(x => x.Order)
|
||||
.Select(x => new
|
||||
{
|
||||
order = x.Order,
|
||||
id = x.Id,
|
||||
reason = x.Reason,
|
||||
remove = x.Remove,
|
||||
profileId = x.Profile.Id,
|
||||
citizenId = x.Profile.CitizenId,
|
||||
prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
|
||||
fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
|
||||
organizationOrganization = x.Profile.OrganizationOrganization,
|
||||
oc = x.Profile.Oc,
|
||||
position = x.Profile.Position == null ? null : x.Profile.Position.Name,
|
||||
positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
|
||||
positionExecutive = x.Profile.PositionExecutive,
|
||||
posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
|
||||
positionEmployeePosition = x.Profile.PositionEmployeePosition,
|
||||
positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
|
||||
positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
|
||||
posNoEmployee = x.Profile.PosNoEmployee,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
return new { retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profile = profile_retireHistory };
|
||||
|
||||
}
|
||||
catch
|
||||
else
|
||||
{
|
||||
throw;
|
||||
var profile_retire = await _dbContext.Set<RetirementProfile>()
|
||||
.Where(x => x.RetirementPeriod == retire)
|
||||
.OrderBy(x => x.Order)
|
||||
.Select(x => new
|
||||
{
|
||||
order = x.Order,
|
||||
id = x.Id,
|
||||
reason = x.Reason,
|
||||
remove = x.Remove,
|
||||
profileId = x.Profile.Id,
|
||||
citizenId = x.Profile.CitizenId,
|
||||
prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
|
||||
fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
|
||||
organizationOrganization = x.Profile.OrganizationOrganization,
|
||||
oc = x.Profile.Oc,
|
||||
position = x.Profile.Position == null ? null : x.Profile.Position.Name,
|
||||
positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
|
||||
positionExecutive = x.Profile.PositionExecutive,
|
||||
posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
|
||||
positionEmployeePosition = x.Profile.PositionEmployeePosition,
|
||||
positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
|
||||
positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
|
||||
posNoEmployee = x.Profile.PosNoEmployee,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
return new { retire.Id, retire.CreatedAt, Year = retire.Year.ToThaiYear().ToString().ToThaiNumber(), retire.Round, retire.Type, retire.TypeReport, Total = profile_retire.Count.ToString().ToThaiNumber(), profile = profile_retire };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue