เพิ่มบิ้วไฟล์excel
This commit is contained in:
parent
4b7715cc8a
commit
bd695abf24
8 changed files with 3127 additions and 332 deletions
|
|
@ -91,4 +91,16 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Templates\ExamList.xlsx">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Templates\PassAExamList.xlsx">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Templates\PassExamList.xlsx">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -112,6 +112,22 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
private int GetExamCountTe(string citizenId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var count = _context.Candidates.AsQueryable()
|
||||
.Where(x => x.CitizenId == citizenId)
|
||||
.Count();
|
||||
|
||||
return count;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<int> GetExamCount(Guid exam)
|
||||
{
|
||||
try
|
||||
|
|
@ -358,71 +374,71 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
// .ThenInclude(x => x.Documents)
|
||||
// .ThenInclude(x => x.DocumentFile)
|
||||
// .FirstOrDefaultAsync(x => x.Id == id);
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.Select(x => new PeriodExamCandidateResponseItem
|
||||
{
|
||||
ExamDate = x.ExamDate,
|
||||
AnnouncementEndDate = x.AnnouncementEndDate,
|
||||
AnnouncementStartDate = x.AnnouncementStartDate,
|
||||
AnnouncementDate = x.AnnouncementDate,
|
||||
CheckDisability = x.CheckDisability,
|
||||
CheckDocument = x.CheckDocument,
|
||||
Detail = x.Detail,
|
||||
Fee = x.Fee,
|
||||
Id = x.Id,
|
||||
IsActive = x.IsActive,
|
||||
Name = x.Name,
|
||||
Note = x.Note,
|
||||
// OrganizationCodeId = x.OrganizationCodeId,
|
||||
// OrganizationCodeName = x.OrganizationCodeName,
|
||||
// OrganizationId = x.OrganizationId,
|
||||
// OrganizationName = x.OrganizationName,
|
||||
PaymentEndDate = x.PaymentEndDate,
|
||||
// PaymentKrungThai = x.PaymentKrungThai,
|
||||
AnnouncementExam = x.AnnouncementExam,
|
||||
Category = x.Category,
|
||||
PaymentStartDate = x.PaymentStartDate,
|
||||
RegisterEndDate = x.RegisterEndDate,
|
||||
RegisterStartDate = x.RegisterStartDate,
|
||||
Round = x.Round,
|
||||
// SetSeat = x.SetSeat,
|
||||
Year = x.Year,
|
||||
// BankExam = x.BankExam.OrderBy(o => o.CreatedAt).Select(b => new BankExam
|
||||
// {
|
||||
// Id = b.Id,
|
||||
// AccountName = b.AccountName,
|
||||
// AccountNumber = b.AccountNumber,
|
||||
// BankName = b.BankName,
|
||||
// }).ToList(),
|
||||
// PositionExam = x.PositionExam.OrderBy(o => o.CreatedAt).Select(b => new PositionExam
|
||||
// {
|
||||
// Id = b.Id,
|
||||
// TypeId = b.TypeId,
|
||||
// TypeName = b.TypeName,
|
||||
// PositionId = b.PositionId,
|
||||
// PositionName = b.PositionName,
|
||||
// }).ToList(),
|
||||
Documents = x.PeriodExamDocuments.OrderBy(o => o.CreatedAt).Select(b => new FileListResponse
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.Select(x => new PeriodExamCandidateResponseItem
|
||||
{
|
||||
Id = b.Document == null ? "" : b.Document.Id.ToString(),
|
||||
FileName = b.Document == null ? "" : b.Document.FileName,
|
||||
FileSize = b.Document == null ? 0 : b.Document.FileSize,
|
||||
FileType = b.Document == null ? "" : b.Document.FileType,
|
||||
Detail = b.Document == null ? "" : b.Document.Id.ToString(),
|
||||
}).ToList(),
|
||||
Images = x.PeriodExamImages.OrderBy(o => o.CreatedAt).Select(b => new FileListResponse
|
||||
{
|
||||
Id = b.Document == null ? "" : b.Document.Id.ToString(),
|
||||
FileName = b.Document == null ? "" : b.Document.FileName,
|
||||
FileSize = b.Document == null ? 0 : b.Document.FileSize,
|
||||
FileType = b.Document == null ? "" : b.Document.FileType,
|
||||
Detail = b.Document == null ? "" : b.Document.Id.ToString(),
|
||||
}).ToList(),
|
||||
})
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
ExamDate = x.ExamDate,
|
||||
AnnouncementEndDate = x.AnnouncementEndDate,
|
||||
AnnouncementStartDate = x.AnnouncementStartDate,
|
||||
AnnouncementDate = x.AnnouncementDate,
|
||||
CheckDisability = x.CheckDisability,
|
||||
CheckDocument = x.CheckDocument,
|
||||
Detail = x.Detail,
|
||||
Fee = x.Fee,
|
||||
Id = x.Id,
|
||||
IsActive = x.IsActive,
|
||||
Name = x.Name,
|
||||
Note = x.Note,
|
||||
// OrganizationCodeId = x.OrganizationCodeId,
|
||||
// OrganizationCodeName = x.OrganizationCodeName,
|
||||
// OrganizationId = x.OrganizationId,
|
||||
// OrganizationName = x.OrganizationName,
|
||||
PaymentEndDate = x.PaymentEndDate,
|
||||
// PaymentKrungThai = x.PaymentKrungThai,
|
||||
AnnouncementExam = x.AnnouncementExam,
|
||||
Category = x.Category,
|
||||
PaymentStartDate = x.PaymentStartDate,
|
||||
RegisterEndDate = x.RegisterEndDate,
|
||||
RegisterStartDate = x.RegisterStartDate,
|
||||
Round = x.Round,
|
||||
// SetSeat = x.SetSeat,
|
||||
Year = x.Year,
|
||||
// BankExam = x.BankExam.OrderBy(o => o.CreatedAt).Select(b => new BankExam
|
||||
// {
|
||||
// Id = b.Id,
|
||||
// AccountName = b.AccountName,
|
||||
// AccountNumber = b.AccountNumber,
|
||||
// BankName = b.BankName,
|
||||
// }).ToList(),
|
||||
// PositionExam = x.PositionExam.OrderBy(o => o.CreatedAt).Select(b => new PositionExam
|
||||
// {
|
||||
// Id = b.Id,
|
||||
// TypeId = b.TypeId,
|
||||
// TypeName = b.TypeName,
|
||||
// PositionId = b.PositionId,
|
||||
// PositionName = b.PositionName,
|
||||
// }).ToList(),
|
||||
Documents = x.PeriodExamDocuments.OrderBy(o => o.CreatedAt).Select(b => new FileListResponse
|
||||
{
|
||||
Id = b.Document == null ? "" : b.Document.Id.ToString(),
|
||||
FileName = b.Document == null ? "" : b.Document.FileName,
|
||||
FileSize = b.Document == null ? 0 : b.Document.FileSize,
|
||||
FileType = b.Document == null ? "" : b.Document.FileType,
|
||||
Detail = b.Document == null ? "" : b.Document.Id.ToString(),
|
||||
}).ToList(),
|
||||
Images = x.PeriodExamImages.OrderBy(o => o.CreatedAt).Select(b => new FileListResponse
|
||||
{
|
||||
Id = b.Document == null ? "" : b.Document.Id.ToString(),
|
||||
FileName = b.Document == null ? "" : b.Document.FileName,
|
||||
FileSize = b.Document == null ? 0 : b.Document.FileSize,
|
||||
FileType = b.Document == null ? "" : b.Document.FileType,
|
||||
Detail = b.Document == null ? "" : b.Document.Id.ToString(),
|
||||
}).ToList(),
|
||||
})
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
return Success(periodExam);
|
||||
}
|
||||
|
|
@ -1601,7 +1617,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
ExamYear = p.PeriodExam.Year == null ? 0 : p.PeriodExam.Year.Value.ToThaiYear(),
|
||||
Score = sr == null ? 0 : sr.SumA + sr.SumB + sr.SumC,
|
||||
Number = sr == null ? "" : sr.Number,
|
||||
ExamCount = _disableService.GetExamCount(p.CitizenId),
|
||||
CitizenId = p.CitizenId,
|
||||
ExamCount = 0,
|
||||
ScoreExpire = p.PeriodExam.AnnouncementDate == null ? "" : p.PeriodExam.AnnouncementDate.AddYears(2).ToThaiShortDate(),
|
||||
ScoreResult = sr == null ? null : new
|
||||
{
|
||||
|
|
@ -1623,7 +1640,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
return Success(data);
|
||||
return Success(new { data, ExamCount = data == null || data.CitizenId == "" ? 0 : GetExamCountTe(data.CitizenId) });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Data
|
|||
{
|
||||
// disable relation setup
|
||||
modelBuilder.Entity<PeriodExam>().HasMany(x => x.Disables).WithOne(x => x.PeriodExam).OnDelete(DeleteBehavior.Cascade);
|
||||
modelBuilder.Entity<Models.Disables.Disable>().HasMany(x => x.Educations).WithOne(x => x.Disable).OnDelete(DeleteBehavior.Cascade);
|
||||
modelBuilder.Entity<Models.Disables.Disable>().HasMany(x => x.Occupations).WithOne(x => x.Disable).OnDelete(DeleteBehavior.Cascade);
|
||||
modelBuilder.Entity<Models.Disables.Disable>().HasMany(x => x.Addresses).WithOne(x => x.Disable).OnDelete(DeleteBehavior.Cascade);
|
||||
modelBuilder.Entity<Models.Disables.Disable>().HasMany(x => x.Certificates).WithOne(x => x.Disable).OnDelete(DeleteBehavior.Cascade);
|
||||
modelBuilder.Entity<Models.Disables.Disable>().HasMany(x => x.Payments).WithOne(x => x.Disable).OnDelete(DeleteBehavior.Cascade);
|
||||
modelBuilder.Entity<Disable>().HasMany(x => x.Educations).WithOne(x => x.Disable).OnDelete(DeleteBehavior.Cascade);
|
||||
modelBuilder.Entity<Disable>().HasMany(x => x.Occupations).WithOne(x => x.Disable).OnDelete(DeleteBehavior.Cascade);
|
||||
modelBuilder.Entity<Disable>().HasMany(x => x.Addresses).WithOne(x => x.Disable).OnDelete(DeleteBehavior.Cascade);
|
||||
modelBuilder.Entity<Disable>().HasMany(x => x.Certificates).WithOne(x => x.Disable).OnDelete(DeleteBehavior.Cascade);
|
||||
modelBuilder.Entity<Disable>().HasMany(x => x.Payments).WithOne(x => x.Disable).OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
|
||||
// public DbSet<Prefix> Prefixes { get; set; }
|
||||
|
|
@ -63,7 +63,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Data
|
|||
|
||||
public DbSet<CMSGovernment> CMSGovernments { get; set; }
|
||||
|
||||
public DbSet<Models.Disables.Disable> Disables { get; set; }
|
||||
public DbSet<Disable> Disables { get; set; }
|
||||
|
||||
public DbSet<DisableAddress> DisableAddresses { get; set; }
|
||||
|
||||
|
|
|
|||
2741
Migrations/20230502083957_update table disable add model.Designer.cs
generated
Normal file
2741
Migrations/20230502083957_update table disable add model.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
22
Migrations/20230502083957_update table disable add model.cs
Normal file
22
Migrations/20230502083957_update table disable add model.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class updatetabledisableaddmodel : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Models.Disables
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,29 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using BMA.EHR.Recurit.Exam.Service.Data;
|
||||
using BMA.EHR.Recurit.Exam.Service.Models.Disables;
|
||||
using System.Data;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||
{
|
||||
public class DisableService
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
|
||||
public DisableService(ApplicationDbContext context)
|
||||
public DisableService(ApplicationDbContext context,
|
||||
IConfiguration configuration,
|
||||
IWebHostEnvironment webHostEnvironment)
|
||||
{
|
||||
_context = context;
|
||||
_configuration = configuration;
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
}
|
||||
|
||||
public int GetExamCount(string citizenId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var count = _context.Disables.AsQueryable()
|
||||
.Where(x => x.CitizenId == citizenId)
|
||||
.Count();
|
||||
var count = _context.Candidates.AsQueryable()
|
||||
.Where(x => x.CitizenId == citizenId)
|
||||
.Count();
|
||||
|
||||
return count;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue