เพิ่ม link สำนักตาม keycloak
This commit is contained in:
parent
0b5c7038a6
commit
86a6ab9514
10 changed files with 712 additions and 289 deletions
|
|
@ -38,6 +38,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
#region " Fields "
|
#region " Fields "
|
||||||
|
|
||||||
private readonly ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
private readonly MetadataDbContext _contextMetadata;
|
||||||
private readonly MinIOService _minioService;
|
private readonly MinIOService _minioService;
|
||||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||||
private readonly DisableService _disableService;
|
private readonly DisableService _disableService;
|
||||||
|
|
@ -50,6 +51,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
#region " Constructor and Destructor "
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
public DisableController(ApplicationDbContext context,
|
public DisableController(ApplicationDbContext context,
|
||||||
|
MetadataDbContext contextMetadata,
|
||||||
MinIOService minioService,
|
MinIOService minioService,
|
||||||
IWebHostEnvironment webHostEnvironment,
|
IWebHostEnvironment webHostEnvironment,
|
||||||
DisableService disableService,
|
DisableService disableService,
|
||||||
|
|
@ -57,6 +59,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
ILogger<DisableController> logger)
|
ILogger<DisableController> logger)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
|
_contextMetadata = contextMetadata;
|
||||||
_minioService = minioService;
|
_minioService = minioService;
|
||||||
_webHostEnvironment = webHostEnvironment;
|
_webHostEnvironment = webHostEnvironment;
|
||||||
_disableService = disableService;
|
_disableService = disableService;
|
||||||
|
|
@ -175,6 +178,32 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private List<Guid?> GetAllIdByRoot(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ret = new List<Guid?>();
|
||||||
|
|
||||||
|
var oc = _contextMetadata.Organizations.FirstOrDefault(x => x.Id == id && x.IsActive);
|
||||||
|
if (oc != null)
|
||||||
|
ret.Add(oc.Id);
|
||||||
|
|
||||||
|
var child = _contextMetadata.Organizations.AsQueryable().Where(x => x.ParentId == id && x.IsActive).ToList();
|
||||||
|
if (child.Any())
|
||||||
|
{
|
||||||
|
foreach (var item in child)
|
||||||
|
{
|
||||||
|
ret.AddRange(GetAllIdByRoot(item.Id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -659,11 +688,48 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||||
ImportDate = x.CreatedAt.Date.ToThaiShortDate(),
|
ImportDate = x.CreatedAt.Date.ToThaiShortDate(),
|
||||||
ScoreCount = x.ScoreImport.Scores.Count(),
|
ScoreCount = x.ScoreImport.Scores.Count(),
|
||||||
|
|
||||||
}
|
},
|
||||||
|
x.CreatedUserId,
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
var profileOrganizations = await _contextMetadata.ProfileOrganizations.AsQueryable()
|
||||||
|
.ToListAsync();
|
||||||
|
var _periodExams = (from x in data
|
||||||
|
join po in profileOrganizations on Guid.Parse(x.CreatedUserId) equals po?.UserId into poGroup
|
||||||
|
from po in poGroup.DefaultIfEmpty()
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
x.Id,
|
||||||
|
x.Year,
|
||||||
|
x.Name,
|
||||||
|
x.Round,
|
||||||
|
x.ImportDate,
|
||||||
|
x.ExamCount,
|
||||||
|
x.CreatedUserId,
|
||||||
|
OcId = po == null ? null : po.OrganizationId,
|
||||||
|
}).AsQueryable()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
return Success(data);
|
var roles = _httpContextAccessor?.HttpContext?.User?.FindAll(ClaimTypes.Role)?.Select(c => c.Value).ToList();
|
||||||
|
if (!roles.Contains("head"))
|
||||||
|
{
|
||||||
|
var criteria = new List<Guid?>();
|
||||||
|
var profileOrganization = await _contextMetadata.ProfileOrganizations.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.UserId == Guid.Parse(UserId));
|
||||||
|
|
||||||
|
if (profileOrganization == null)
|
||||||
|
throw new Exception(GlobalMessages.OrganizationNotFound);
|
||||||
|
|
||||||
|
var ocId = _contextMetadata.Organizations.AsQueryable()
|
||||||
|
.FirstOrDefault(x => x.Id == profileOrganization.OrganizationId);
|
||||||
|
if (ocId == null)
|
||||||
|
throw new Exception(GlobalMessages.OrganizationNotFound);
|
||||||
|
criteria = GetAllIdByRoot(ocId.Id);
|
||||||
|
if (criteria.Any())
|
||||||
|
_periodExams = _periodExams.Where(x => x.CreatedUserId == UserId || criteria.Contains(x.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OcId)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Success(_periodExams);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,5 +23,6 @@
|
||||||
public const string ReligionNotFound = "ไม่พบข้อมูลศาสนา";
|
public const string ReligionNotFound = "ไม่พบข้อมูลศาสนา";
|
||||||
public const string SubDistrictNotFound = "ไม่พบข้อมูลตำบล/แขวง";
|
public const string SubDistrictNotFound = "ไม่พบข้อมูลตำบล/แขวง";
|
||||||
public const string CMSNotFound = "ไม่พบข้อมูล CMS";
|
public const string CMSNotFound = "ไม่พบข้อมูล CMS";
|
||||||
|
public const string OrganizationNotFound = "ไม่พบข้อมูลสังกัด";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Data
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public DbSet<BMA.EHR.Profile.Service.Models.HR.ProfileOrganization> ProfileOrganizations { get; set; }
|
||||||
|
public DbSet<BMA.EHR.Profile.Service.Models.HR.Profile> Profiles { get; set; }
|
||||||
|
public DbSet<BMA.EHR.Profile.Service.Models.HR.OrganizationEntity> Organizations { get; set; }
|
||||||
|
|
||||||
public DbSet<Prefix> Prefixes { get; set; }
|
public DbSet<Prefix> Prefixes { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,5 +28,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
|
||||||
|
|
||||||
[Column(Order = 105), Comment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"), MaxLength(200)]
|
[Column(Order = 105), Comment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด"), MaxLength(200)]
|
||||||
public string LastUpdateFullName { get; set; } = string.Empty;
|
public string LastUpdateFullName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Column(Order = 106), Comment("สถานะการใช้งาน")]
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
73
Models/HR/OrganizationEntity.cs
Normal file
73
Models/HR/OrganizationEntity.cs
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using BMA.EHR.Recurit.Exam.Service.Models;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Profile.Service.Models.HR
|
||||||
|
{
|
||||||
|
public class OrganizationEntity : EntityBase
|
||||||
|
{
|
||||||
|
|
||||||
|
//[ForeignKey("OrganizationOrganizationId")]
|
||||||
|
//public OrganizationOrganization? OrganizationOrganization_OrganizationOrganizationId { get; set; }
|
||||||
|
|
||||||
|
[Column(Order = 2), Comment("OrganizationOrganizationId")]
|
||||||
|
public Guid? OrganizationOrganizationId { get; set; }
|
||||||
|
|
||||||
|
//[ForeignKey("OrganizationShortNameId")]
|
||||||
|
//public OrganizationShortName? OrganizationShortName_OrganizationShortNameId { get; set; }
|
||||||
|
|
||||||
|
[Column(Order = 3), Comment("OrganizationShortNameId")]
|
||||||
|
public Guid? OrganizationShortNameId { get; set; }
|
||||||
|
|
||||||
|
//[ForeignKey("OrganizationTypeId")]
|
||||||
|
//public OrganizationType? OrganizationType_OrganizationTypeId { get; set; }
|
||||||
|
|
||||||
|
[Column(Order = 4), Comment("OrganizationTypeId")]
|
||||||
|
public Guid? OrganizationTypeId { get; set; }
|
||||||
|
|
||||||
|
//[ForeignKey("OrganizationLevelId")]
|
||||||
|
//public OrganizationLevel? OrganizationLevel_OrganizationLevelId { get; set; }
|
||||||
|
|
||||||
|
[Column(Order = 5), Comment("OrganizationLevelId")]
|
||||||
|
public Guid? OrganizationLevelId { get; set; }
|
||||||
|
|
||||||
|
//[ForeignKey("OrganizationTelExternalId")]
|
||||||
|
//public OrganizationTelExternal? OrganizationTelExternal_OrganizationTelExternalId { get; set; }
|
||||||
|
|
||||||
|
[Column(Order = 6), Comment("OrganizationTelExternalId")]
|
||||||
|
public Guid? OrganizationTelExternalId { get; set; }
|
||||||
|
|
||||||
|
//[ForeignKey("OrganizationTelInternalId")]
|
||||||
|
//public OrganizationTelInternal? OrganizationTelInternal_OrganizationTelInternalId { get; set; }
|
||||||
|
|
||||||
|
[Column(Order = 7), Comment("OrganizationTelInternalId")]
|
||||||
|
public Guid? OrganizationTelInternalId { get; set; }
|
||||||
|
|
||||||
|
//[ForeignKey("OrganizationFaxId")]
|
||||||
|
//public OrganizationFax? OrganizationFax_OrganizationFaxId { get; set; }
|
||||||
|
|
||||||
|
[Column(Order = 8), Comment("OrganizationFaxId")]
|
||||||
|
public Guid? OrganizationFaxId { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("ParentId")]
|
||||||
|
public OrganizationEntity? Organization_ParentId { get; set; }
|
||||||
|
|
||||||
|
[Column(Order = 9), Comment("ParentId")]
|
||||||
|
public Guid? ParentId { get; set; }
|
||||||
|
|
||||||
|
[Column(Order = 10), Comment("OrganizationAgencyId")]
|
||||||
|
public Guid? OrganizationAgencyId { get; set; }
|
||||||
|
|
||||||
|
[Column(Order = 11), Comment("OrganizationGovernmentAgencyId")]
|
||||||
|
public Guid? OrganizationGovernmentAgencyId { get; set; }
|
||||||
|
|
||||||
|
[Column(Order = 12), Comment("OrganizationOrder")]
|
||||||
|
public int? OrganizationOrder { get; set; }
|
||||||
|
|
||||||
|
[Column(Order = 13), Comment("OrganizationUserNote")]
|
||||||
|
public string? OrganizationUserNote { get; set; }
|
||||||
|
|
||||||
|
public List<OrganizationEntity> Organizations { get; } = new();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
210
Models/HR/Profile.cs
Normal file
210
Models/HR/Profile.cs
Normal file
|
|
@ -0,0 +1,210 @@
|
||||||
|
using BMA.EHR.Recurit.Exam.Service.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Profile.Service.Models.HR
|
||||||
|
{
|
||||||
|
public class Profile : EntityBase
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(13)]
|
||||||
|
public string? CitizenId { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(50)]
|
||||||
|
public string? ProfileType { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(20)]
|
||||||
|
public string? EmployeeType { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(20)]
|
||||||
|
public string? EmployeeClass { get; set; }
|
||||||
|
|
||||||
|
public Guid? PrefixId { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
[Required]
|
||||||
|
public string? FirstName { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
[Required]
|
||||||
|
public string? LastName { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string AvatarRef { get; set; }
|
||||||
|
|
||||||
|
public Guid? GenderId { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string? Nationality { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string? Race { get; set; }
|
||||||
|
|
||||||
|
public Guid? ReligionId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public DateTime BirthDate { get; set; }
|
||||||
|
|
||||||
|
public Guid? BloodGroupId { get; set; }
|
||||||
|
|
||||||
|
public Guid? RelationshipId { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(50)]
|
||||||
|
public string? TelephoneNumber { get; set; }
|
||||||
|
|
||||||
|
public bool? Couple { get; set; }
|
||||||
|
|
||||||
|
public Guid? CouplePrefixId { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string? CoupleFirstName { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string? CoupleLastName { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string? CoupleCareer { get; set; }
|
||||||
|
|
||||||
|
public Guid? FatherPrefixId { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string? FatherFirstName { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string? FatherLastName { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string? FatherCareer { get; set; }
|
||||||
|
|
||||||
|
public Guid? MotherPrefixId { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string? MotherFirstName { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string? MotherLastName { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string? MotherCareer { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(200)]
|
||||||
|
public string? CurrentAddress { get; set; }
|
||||||
|
|
||||||
|
public Guid? CurrentSubDistrictId { get; set; }
|
||||||
|
|
||||||
|
public Guid? CurrentDistrictId { get; set; }
|
||||||
|
|
||||||
|
public Guid? CurrentProvinceId { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(5)]
|
||||||
|
public string? CurrentZipCode { get; set; }
|
||||||
|
|
||||||
|
public bool? RegistrationSame { get; set; } = false;
|
||||||
|
|
||||||
|
[MaxLength(200)]
|
||||||
|
public string? RegistrationAddress { get; set; }
|
||||||
|
|
||||||
|
public Guid? RegistrationSubDistrictId { get; set; }
|
||||||
|
|
||||||
|
public Guid? RegistrationDistrictId { get; set; }
|
||||||
|
|
||||||
|
public Guid? RegistrationProvinceId { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(5)]
|
||||||
|
public string? RegistrationZipCode { get; set; }
|
||||||
|
|
||||||
|
public DateTime? DateAppoint { get; set; }
|
||||||
|
|
||||||
|
public DateTime? DateStart { get; set; }
|
||||||
|
|
||||||
|
public DateTime? DateRetire { get; set; }
|
||||||
|
|
||||||
|
// public Guid? AffiliationId { get; set; }
|
||||||
|
// public Guid? PositionId { get; set; }
|
||||||
|
// public Guid? WorkId { get; set; }
|
||||||
|
// public Guid? TypeId { get; set; }
|
||||||
|
// public Guid? LevelId { get; set; }
|
||||||
|
// public Guid? NumberId { get; set; }
|
||||||
|
// public Guid? BusinessId { get; set; }
|
||||||
|
// public Guid? OcId { get; set; }
|
||||||
|
// public Guid? PositionId { get; set; }
|
||||||
|
// public Guid? PosNoId { get; set; }
|
||||||
|
public Guid? OcId { get; set; }
|
||||||
|
public string? Oc { get; set; }
|
||||||
|
public Guid? OrganizationShortNameId { get; set; }
|
||||||
|
public string? OrganizationShortName { get; set; }
|
||||||
|
|
||||||
|
public string? GovernmentCode { get; set; }
|
||||||
|
|
||||||
|
public Guid? OrganizationOrganizationId { get; set; }
|
||||||
|
public string? OrganizationOrganization { get; set; }
|
||||||
|
public Guid? PositionId { get; set; }
|
||||||
|
public string? Position { get; set; }
|
||||||
|
public Guid? PosNoId { get; set; }
|
||||||
|
public string? PosNo { get; set; }
|
||||||
|
public Guid? PositionLineId { get; set; }
|
||||||
|
public string? PositionLine { get; set; }
|
||||||
|
public Guid? PositionPathSideId { get; set; }
|
||||||
|
public string? PositionPathSide { get; set; }
|
||||||
|
public Guid? PositionTypeId { get; set; }
|
||||||
|
public string? PositionType { get; set; }
|
||||||
|
public Guid? PositionLevelId { get; set; }
|
||||||
|
public string? PositionLevel { get; set; }
|
||||||
|
public Guid? PositionExecutiveId { get; set; }
|
||||||
|
public string? PositionExecutive { get; set; }
|
||||||
|
public Guid? PositionExecutiveSideId { get; set; }
|
||||||
|
public string? PositionExecutiveSide { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string Physical { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string Ability { get; set; }
|
||||||
|
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
|
||||||
|
public bool IsLeave { get; set; } = false;
|
||||||
|
|
||||||
|
public DateTime? LeaveDate { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(1000)]
|
||||||
|
public string? LeaveReason { get; set; }
|
||||||
|
|
||||||
|
public DateTime? CreatedDate { get; set; }
|
||||||
|
|
||||||
|
public DateTime? ModifiedDate { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(250)]
|
||||||
|
public string CreatedUser { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[MaxLength(5)]
|
||||||
|
public string EntryStatus { get; set; } = "st1"; // สถานะการตรวจสอบ st1 = create; st2 = pending
|
||||||
|
|
||||||
|
public bool IsTransfer { get; set; } = false;
|
||||||
|
|
||||||
|
public DateTime? TransferDate { get; set; }
|
||||||
|
|
||||||
|
public int GovAgeAbsent { get; set; } = 0;
|
||||||
|
|
||||||
|
public int GovAgePlus { get; set; } = 0;
|
||||||
|
|
||||||
|
// public OrganizationEntity? Organization { get; set; }
|
||||||
|
|
||||||
|
// public PositionNumberEntity PositionNumber { get; set; }
|
||||||
|
|
||||||
|
// public Position Position { get; set; }
|
||||||
|
|
||||||
|
// public PositionExecutive PositionExecutive { get; set; }
|
||||||
|
|
||||||
|
public bool IsVerified { get; set; } = false;
|
||||||
|
|
||||||
|
[MaxLength(100)]
|
||||||
|
public string VerifiedUser { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime? VerifiedDate { get; set; }
|
||||||
|
|
||||||
|
public bool IsProbation { get; set; } = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
10
Models/HR/ProfileOrganization.cs
Normal file
10
Models/HR/ProfileOrganization.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
using BMA.EHR.Recurit.Exam.Service.Models;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Profile.Service.Models.HR
|
||||||
|
{
|
||||||
|
public class ProfileOrganization : EntityBase
|
||||||
|
{
|
||||||
|
public Guid? OrganizationId { get; set; }
|
||||||
|
public Guid? UserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
|
||||||
public bool CheckDisability { get; set; }
|
public bool CheckDisability { get; set; }
|
||||||
public int? Round { get; set; }
|
public int? Round { get; set; }
|
||||||
public int? Year { get; set; }
|
public int? Year { get; set; }
|
||||||
|
public Guid? OcId { get; set; }
|
||||||
|
public string CreatedUserId { get; set; }
|
||||||
public float? Fee { get; set; }
|
public float? Fee { get; set; }
|
||||||
public DateTime RegisterStartDate { get; set; }
|
public DateTime RegisterStartDate { get; set; }
|
||||||
public DateTime RegisterEndDate { get; set; }
|
public DateTime RegisterEndDate { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -84,43 +84,98 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Guid?> GetAllIdByRoot(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ret = new List<Guid?>();
|
||||||
|
|
||||||
|
var oc = _contextMetadata.Organizations.FirstOrDefault(x => x.Id == id && x.IsActive);
|
||||||
|
if (oc != null)
|
||||||
|
ret.Add(oc.Id);
|
||||||
|
|
||||||
|
var child = _contextMetadata.Organizations.AsQueryable().Where(x => x.ParentId == id && x.IsActive).ToList();
|
||||||
|
if (child.Any())
|
||||||
|
{
|
||||||
|
foreach (var item in child)
|
||||||
|
{
|
||||||
|
ret.AddRange(GetAllIdByRoot(item.Id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<PeriodExamCandidateResponseItem>> GetsAsync(string type, bool showAll = true)
|
public async Task<IEnumerable<PeriodExamCandidateResponseItem>> GetsAsync(string type, bool showAll = true)
|
||||||
{
|
{
|
||||||
return await _context.PeriodExams.AsQueryable()
|
var periodExams = await _context.PeriodExams.AsQueryable()
|
||||||
.Where(p => p.IsActive)
|
.Where(p => p.IsActive)
|
||||||
.Where(p => p.CheckDisability == false)
|
.Where(p => p.CheckDisability == false)
|
||||||
.Where(p => type.ToUpper() == "ALL" ? (p.AnnouncementExam == true || p.AnnouncementExam == false) : (type.ToUpper() == "EXAM" ? p.AnnouncementExam == true : p.AnnouncementExam == false))
|
.Where(p => type.ToUpper() == "ALL" ? (p.AnnouncementExam == true || p.AnnouncementExam == false) : (type.ToUpper() == "EXAM" ? p.AnnouncementExam == true : p.AnnouncementExam == false))
|
||||||
.OrderByDescending(d => d.CreatedAt)
|
.OrderByDescending(d => d.CreatedAt).ToListAsync();
|
||||||
.Select(x => new PeriodExamCandidateResponseItem
|
var profileOrganizations = await _contextMetadata.ProfileOrganizations.AsQueryable()
|
||||||
{
|
.ToListAsync();
|
||||||
ExamDate = x.ExamDate,
|
var _periodExams = (from x in periodExams
|
||||||
AnnouncementEndDate = x.AnnouncementEndDate,
|
join po in profileOrganizations on Guid.Parse(x.CreatedUserId) equals po?.UserId into poGroup
|
||||||
AnnouncementStartDate = x.AnnouncementStartDate,
|
from po in poGroup.DefaultIfEmpty()
|
||||||
AnnouncementDate = x.AnnouncementDate,
|
select new PeriodExamCandidateResponseItem
|
||||||
CheckDisability = x.CheckDisability,
|
{
|
||||||
CheckDocument = x.CheckDocument,
|
ExamDate = x.ExamDate,
|
||||||
Detail = x.Detail,
|
AnnouncementEndDate = x.AnnouncementEndDate,
|
||||||
Fee = x.Fee,
|
AnnouncementStartDate = x.AnnouncementStartDate,
|
||||||
Id = x.Id,
|
AnnouncementDate = x.AnnouncementDate,
|
||||||
IsActive = x.IsActive,
|
CheckDisability = x.CheckDisability,
|
||||||
Name = x.Name,
|
CheckDocument = x.CheckDocument,
|
||||||
Note = x.Note,
|
Detail = x.Detail,
|
||||||
OrganizationCodeId = x.OrganizationCodeId,
|
Fee = x.Fee,
|
||||||
OrganizationCodeName = x.OrganizationCodeName,
|
Id = x.Id,
|
||||||
OrganizationId = x.OrganizationId,
|
IsActive = x.IsActive,
|
||||||
OrganizationName = x.OrganizationName,
|
Name = x.Name,
|
||||||
PaymentEndDate = x.PaymentEndDate,
|
Note = x.Note,
|
||||||
PaymentKrungThai = x.PaymentKrungThai,
|
OrganizationCodeId = x.OrganizationCodeId,
|
||||||
AnnouncementExam = x.AnnouncementExam,
|
OrganizationCodeName = x.OrganizationCodeName,
|
||||||
Category = x.Category,
|
OrganizationId = x.OrganizationId,
|
||||||
PaymentStartDate = x.PaymentStartDate,
|
OrganizationName = x.OrganizationName,
|
||||||
RegisterEndDate = x.RegisterEndDate,
|
PaymentEndDate = x.PaymentEndDate,
|
||||||
RegisterStartDate = x.RegisterStartDate,
|
PaymentKrungThai = x.PaymentKrungThai,
|
||||||
Round = x.Round,
|
AnnouncementExam = x.AnnouncementExam,
|
||||||
SetSeat = x.SetSeat,
|
Category = x.Category,
|
||||||
Year = x.Year,
|
PaymentStartDate = x.PaymentStartDate,
|
||||||
})
|
RegisterEndDate = x.RegisterEndDate,
|
||||||
.ToListAsync();
|
RegisterStartDate = x.RegisterStartDate,
|
||||||
|
Round = x.Round,
|
||||||
|
SetSeat = x.SetSeat,
|
||||||
|
Year = x.Year,
|
||||||
|
OcId = po == null ? null : po.OrganizationId,
|
||||||
|
CreatedUserId = x.CreatedUserId,
|
||||||
|
}).AsQueryable()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var roles = _httpContextAccessor?.HttpContext?.User?.FindAll(ClaimTypes.Role)?.Select(c => c.Value).ToList();
|
||||||
|
if (!roles.Contains("head"))
|
||||||
|
{
|
||||||
|
var criteria = new List<Guid?>();
|
||||||
|
var profileOrganization = await _contextMetadata.ProfileOrganizations.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.UserId == Guid.Parse(UserId));
|
||||||
|
|
||||||
|
if (profileOrganization == null)
|
||||||
|
throw new Exception(GlobalMessages.OrganizationNotFound);
|
||||||
|
|
||||||
|
var ocId = _contextMetadata.Organizations.AsQueryable()
|
||||||
|
.FirstOrDefault(x => x.Id == profileOrganization.OrganizationId);
|
||||||
|
if (ocId == null)
|
||||||
|
throw new Exception(GlobalMessages.OrganizationNotFound);
|
||||||
|
criteria = GetAllIdByRoot(ocId.Id);
|
||||||
|
|
||||||
|
if (criteria.Any())
|
||||||
|
_periodExams = _periodExams.Where(x => x.CreatedUserId == UserId || criteria.Contains(x.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OcId)).ToList();
|
||||||
|
}
|
||||||
|
return _periodExams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<PeriodExamCandidateResponseItem?> GetsExamAndCandidateAsync(string examId, bool showAll = true)
|
public async Task<PeriodExamCandidateResponseItem?> GetsExamAndCandidateAsync(string examId, bool showAll = true)
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue