ทmark alet insignia
This commit is contained in:
parent
b7027ebe55
commit
9692af553b
9 changed files with 16687 additions and 241 deletions
|
|
@ -5858,258 +5858,259 @@ namespace BMA.EHR.Application.Repositories
|
||||||
Status = h.Status,
|
Status = h.Status,
|
||||||
RequestNote = h.ReasonReject,
|
RequestNote = h.ReasonReject,
|
||||||
Reason = h.Reason,
|
Reason = h.Reason,
|
||||||
|
MarkALert = h.MarkALert == null ? new List<string>() : JsonConvert.DeserializeObject<List<string>>(h.MarkALert),
|
||||||
// Docs = GetDocFile(h.Profile.Id),
|
// Docs = GetDocFile(h.Profile.Id),
|
||||||
MatchingConditions = h.MatchingConditions == null ? null : JsonConvert.DeserializeObject<List<MatchingCondition>>(h.MatchingConditions)
|
MatchingConditions = h.MatchingConditions == null ? null : JsonConvert.DeserializeObject<List<MatchingCondition>>(h.MatchingConditions)
|
||||||
})).ToList();
|
})).ToList();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// เช็คข้อมูลนำเข้า กับข้อมูลที่อยู่ใน database
|
// เช็คข้อมูลนำเข้า กับข้อมูลที่อยู่ใน database
|
||||||
// public async List<InsigniaRequestProfile> GetDuplicate(List<InsigniaRequestProfile> income, Guid period, Guid ocId, bool Duplicate = false)
|
// public async List<InsigniaRequestProfile> GetDuplicate(List<InsigniaRequestProfile> income, Guid period, Guid ocId, bool Duplicate = false)
|
||||||
// {
|
// {
|
||||||
// try
|
// try
|
||||||
// {
|
// {
|
||||||
// var id = GetRequestId(period, ocId);
|
// var id = GetRequestId(period, ocId);
|
||||||
|
|
||||||
// var req = await _dbContext.Set<InsigniaRequests>().FirstOrDefault(x => x.Id == id);
|
// var req = await _dbContext.Set<InsigniaRequests>().FirstOrDefault(x => x.Id == id);
|
||||||
|
|
||||||
// if (req == null)
|
// if (req == null)
|
||||||
// throw new Exception(GlobalMessages.InsigniaNotFound);
|
// throw new Exception(GlobalMessages.InsigniaNotFound);
|
||||||
|
|
||||||
// var profile = await _dbContext.Set<InsigniaRequestsProfiles>().AsQueryable()
|
// var profile = await _dbContext.Set<InsigniaRequestsProfiles>().AsQueryable()
|
||||||
// .Include(x => x.RequestInsignia)
|
// .Include(x => x.RequestInsignia)
|
||||||
// .ThenInclude(x => x.InsigniaType)
|
// .ThenInclude(x => x.InsigniaType)
|
||||||
// .Include(x => x.Profile)
|
// .Include(x => x.Profile)
|
||||||
// .ThenInclude(x => x.Insignias)
|
// .ThenInclude(x => x.Insignias)
|
||||||
// .Where(x => x.Request.Id == id)
|
// .Where(x => x.Request.Id == id)
|
||||||
// .Select(h => new DuplicateProfile
|
// .Select(h => new DuplicateProfile
|
||||||
// {
|
// {
|
||||||
// ProfileId = h.Profile.Id,
|
// ProfileId = h.Profile.Id,
|
||||||
// IsApprove = h.IsApprove,
|
// IsApprove = h.IsApprove,
|
||||||
// RequestQualificationStatus = h.QualificationStatus,
|
// RequestQualificationStatus = h.QualificationStatus,
|
||||||
// RequestDocumentStatus = h.DocumentStatus,
|
// RequestDocumentStatus = h.DocumentStatus,
|
||||||
// Special = h.Special
|
// Special = h.Special
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// var newIncome = income.GroupJoin(profile,
|
// var newIncome = income.GroupJoin(profile,
|
||||||
// pdb => pdb.Profile.Id,
|
// pdb => pdb.Profile.Id,
|
||||||
// dp => dp.ProfileId,
|
// dp => dp.ProfileId,
|
||||||
// (pdb, dp) => new
|
// (pdb, dp) => new
|
||||||
// {
|
// {
|
||||||
// Profile = pdb.Profile,
|
// Profile = pdb.Profile,
|
||||||
// pdb.Profile.Insignias,
|
// pdb.Profile.Insignias,
|
||||||
// pdb.RequestInsignia,
|
// pdb.RequestInsignia,
|
||||||
// //pdb.RequestInsignia.InsigniaType,
|
// //pdb.RequestInsignia.InsigniaType,
|
||||||
// pdb.Salary,
|
// pdb.Salary,
|
||||||
// pdb.RequestDate,
|
// pdb.RequestDate,
|
||||||
// ProfileDB = dp
|
// ProfileDB = dp
|
||||||
// })
|
// })
|
||||||
// .ToList()
|
// .ToList()
|
||||||
// .Where(d => !Duplicate ? d.ProfileDB.Count() == 0 : d.ProfileDB.Count() != 0)
|
// .Where(d => !Duplicate ? d.ProfileDB.Count() == 0 : d.ProfileDB.Count() != 0)
|
||||||
// .Select(d => !Duplicate ? new InsigniaRequestProfile
|
// .Select(d => !Duplicate ? new InsigniaRequestProfile
|
||||||
// {
|
// {
|
||||||
// Request = req,
|
// Request = req,
|
||||||
// Profile = d.Profile,
|
// Profile = d.Profile,
|
||||||
// RequestInsignia = d.RequestInsignia,
|
// RequestInsignia = d.RequestInsignia,
|
||||||
// Salary = d.Salary,
|
// Salary = d.Salary,
|
||||||
// RequestDate = d.RequestDate,
|
// RequestDate = d.RequestDate,
|
||||||
// } : new InsigniaRequestProfile
|
// } : new InsigniaRequestProfile
|
||||||
// {
|
// {
|
||||||
// Request = req,
|
// Request = req,
|
||||||
// Profile = d.Profile,
|
// Profile = d.Profile,
|
||||||
// RequestInsignia = d.RequestInsignia,
|
// RequestInsignia = d.RequestInsignia,
|
||||||
// Salary = d.Salary,
|
// Salary = d.Salary,
|
||||||
// RequestDate = d.RequestDate,
|
// RequestDate = d.RequestDate,
|
||||||
// IsApprove = d.ProfileDB.First().IsApprove,
|
// IsApprove = d.ProfileDB.First().IsApprove,
|
||||||
// QualificationStatus = d.ProfileDB.First().RequestQualificationStatus,
|
// QualificationStatus = d.ProfileDB.First().RequestQualificationStatus,
|
||||||
// DocumentStatus = d.ProfileDB.First().RequestDocumentStatus,
|
// DocumentStatus = d.ProfileDB.First().RequestDocumentStatus,
|
||||||
// Special = d.ProfileDB.First().Special
|
// Special = d.ProfileDB.First().Special
|
||||||
// })
|
// })
|
||||||
// .ToList();
|
// .ToList();
|
||||||
|
|
||||||
// return newIncome;
|
// return newIncome;
|
||||||
// }
|
// }
|
||||||
// catch
|
// catch
|
||||||
// {
|
// {
|
||||||
// throw;
|
// throw;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// ลบข้อมูลใน db ที่ไม่เท่ากับ income
|
// ลบข้อมูลใน db ที่ไม่เท่ากับ income
|
||||||
// public async List<InsigniaRequestProfile> DeleteProfile(List<InsigniaRequestProfile> income, Guid period, Guid ocId)
|
// public async List<InsigniaRequestProfile> DeleteProfile(List<InsigniaRequestProfile> income, Guid period, Guid ocId)
|
||||||
// {
|
// {
|
||||||
// try
|
// try
|
||||||
// {
|
// {
|
||||||
// var id = GetRequestId(period, ocId);
|
// var id = GetRequestId(period, ocId);
|
||||||
|
|
||||||
// var incomProfileId = income.Select(i => i.Profile.Id).ToList();
|
// var incomProfileId = income.Select(i => i.Profile.Id).ToList();
|
||||||
|
|
||||||
// var arrayData = await _dbContext.Set<InsigniaRequestsProfiles>().AsQueryable()
|
// var arrayData = await _dbContext.Set<InsigniaRequestsProfiles>().AsQueryable()
|
||||||
// .Where(i => !(incomProfileId.Contains(i.Profile.Id)) && i.Request.Id == id)
|
// .Where(i => !(incomProfileId.Contains(i.Profile.Id)) && i.Request.Id == id)
|
||||||
// .ToList();
|
// .ToList();
|
||||||
|
|
||||||
// return arrayData;
|
// return arrayData;
|
||||||
// }
|
// }
|
||||||
// catch
|
// catch
|
||||||
// {
|
// {
|
||||||
// throw;
|
// throw;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// insert candidate list
|
// insert candidate list
|
||||||
public async Task InsertCandidate(Guid periodId, Guid ocId, List<InsigniaResultSet> items)
|
public async Task InsertCandidate(Guid periodId, Guid ocId, List<InsigniaResultSet> items)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||||
|
|
||||||
|
if (period == null)
|
||||||
|
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||||
|
|
||||||
|
var periodOlds = await _dbContext.Set<InsigniaPeriod>().Where(p => p.Year == period.Year).ToListAsync();
|
||||||
|
foreach (var periodOld in periodOlds)
|
||||||
{
|
{
|
||||||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
var requestOlds = await _dbContext.Set<InsigniaRequest>().Where(p => p.Period == periodOld).ToListAsync();
|
||||||
|
foreach (var requestOld in requestOlds)
|
||||||
if (period == null)
|
|
||||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
|
||||||
|
|
||||||
var periodOlds = await _dbContext.Set<InsigniaPeriod>().Where(p => p.Year == period.Year).ToListAsync();
|
|
||||||
foreach (var periodOld in periodOlds)
|
|
||||||
{
|
{
|
||||||
var requestOlds = await _dbContext.Set<InsigniaRequest>().Where(p => p.Period == periodOld).ToListAsync();
|
var profileOlds = await _dbContext.Set<InsigniaRequestProfile>().Where(p => p.Request == requestOld).Select(x => x.Profile.Id).ToListAsync();
|
||||||
foreach (var requestOld in requestOlds)
|
items = items.Where(x => !profileOlds.Contains(x.ProfileId)).ToList();
|
||||||
{
|
|
||||||
var profileOlds = await _dbContext.Set<InsigniaRequestProfile>().Where(p => p.Request == requestOld).Select(x => x.Profile.Id).ToListAsync();
|
|
||||||
items = items.Where(x => !profileOlds.Contains(x.ProfileId)).ToList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
|
||||||
|
|
||||||
if (oc == null)
|
|
||||||
throw new Exception(GlobalMessages.OCNotFound);
|
|
||||||
|
|
||||||
var req = new InsigniaRequest
|
|
||||||
{
|
|
||||||
Period = period,
|
|
||||||
Organization = oc,
|
|
||||||
RequestStatus = "st1",
|
|
||||||
RequestNote = "",
|
|
||||||
CreatedUserId = UserId ?? "System Administrator",
|
|
||||||
CreatedFullName = FullName ?? "",
|
|
||||||
CreatedAt = DateTime.Now,
|
|
||||||
LastUpdateFullName = FullName ?? "System Administrator",
|
|
||||||
LastUpdateUserId = UserId ?? "",
|
|
||||||
LastUpdatedAt = DateTime.Now,
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var item in items)
|
|
||||||
{
|
|
||||||
var pf = await _dbContext.Set<Profile>().FirstOrDefaultAsync(p => p.Id == item.ProfileId);
|
|
||||||
var req_insignia = await _dbContext.Set<Insignia>().FirstOrDefaultAsync(i => i.Id == item.RequestInsignia.Id);
|
|
||||||
|
|
||||||
if (pf != null)
|
|
||||||
{
|
|
||||||
req.RequestProfiles.Add(new InsigniaRequestProfile
|
|
||||||
{
|
|
||||||
Status = "PENDING",
|
|
||||||
Profile = pf,
|
|
||||||
RequestInsignia = req_insignia,
|
|
||||||
Salary = item.Salary == null ? null : item.Salary,
|
|
||||||
RequestDate = DateTime.Now,
|
|
||||||
MatchingConditions = System.Text.Json.JsonSerializer.Serialize(item.MatchingConditions), // serialize to string
|
|
||||||
CreatedUserId = UserId ?? "System Administrator",
|
|
||||||
CreatedFullName = FullName ?? "",
|
|
||||||
CreatedAt = DateTime.Now,
|
|
||||||
LastUpdateFullName = FullName ?? "System Administrator",
|
|
||||||
LastUpdateUserId = UserId ?? "",
|
|
||||||
LastUpdatedAt = DateTime.Now,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await _dbContext.Set<InsigniaRequest>().AddAsync(req);
|
|
||||||
await _dbContext.SaveChangesAsync();
|
|
||||||
}
|
}
|
||||||
catch
|
|
||||||
|
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||||
|
|
||||||
|
if (oc == null)
|
||||||
|
throw new Exception(GlobalMessages.OCNotFound);
|
||||||
|
|
||||||
|
var req = new InsigniaRequest
|
||||||
{
|
{
|
||||||
throw;
|
Period = period,
|
||||||
|
Organization = oc,
|
||||||
|
RequestStatus = "st1",
|
||||||
|
RequestNote = "",
|
||||||
|
CreatedUserId = UserId ?? "System Administrator",
|
||||||
|
CreatedFullName = FullName ?? "",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
var pf = await _dbContext.Set<Profile>().FirstOrDefaultAsync(p => p.Id == item.ProfileId);
|
||||||
|
var req_insignia = await _dbContext.Set<Insignia>().FirstOrDefaultAsync(i => i.Id == item.RequestInsignia.Id);
|
||||||
|
|
||||||
|
if (pf != null)
|
||||||
|
{
|
||||||
|
req.RequestProfiles.Add(new InsigniaRequestProfile
|
||||||
|
{
|
||||||
|
Status = "PENDING",
|
||||||
|
Profile = pf,
|
||||||
|
RequestInsignia = req_insignia,
|
||||||
|
Salary = item.Salary == null ? null : item.Salary,
|
||||||
|
RequestDate = DateTime.Now,
|
||||||
|
MatchingConditions = System.Text.Json.JsonSerializer.Serialize(item.MatchingConditions), // serialize to string
|
||||||
|
CreatedUserId = UserId ?? "System Administrator",
|
||||||
|
CreatedFullName = FullName ?? "",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await _dbContext.Set<InsigniaRequest>().AddAsync(req);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
// เช็คข้อมูลใน kp7insignia
|
|
||||||
// public async ProfileInsignia ListKp7Insignia(string name, string profile, int year)
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// var item = await _dbContext.Set<ProfileInsignias>().AsQueryable()
|
|
||||||
// .Include(x => x.Insignia)
|
|
||||||
// .Include(x => x.Profile)
|
|
||||||
// .FirstOrDefault(x => x.Profile.Id == profile &&
|
|
||||||
// x.Year == year &&
|
|
||||||
// x.Insignia.Name.Contains(name));
|
|
||||||
|
|
||||||
// return item;
|
|
||||||
// }
|
|
||||||
// catch
|
|
||||||
// {
|
|
||||||
// throw;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// บันทึกข้อมูลลง กพ.7
|
|
||||||
// public async ProfileInsignia InsertKp7Insignia(InsigniaKp7Item kp7, InsigniaProfile profile)
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// var pf = await _dbContext.Set<Profiles>().FirstOrDefault(x => x.Id == profile.FkProfileId);
|
|
||||||
// var insignia = await _dbContext.Set<Insignias>().FirstOrDefault(x => x.Name == profile.InsigniaName);
|
|
||||||
|
|
||||||
// var kp7Insignia = new ProfileInsignia
|
|
||||||
// {
|
|
||||||
// Profile = pf,
|
|
||||||
// Year = DateTime.Now.Year,
|
|
||||||
// DateReceive = kp7.InsigniaDatereceive.Value,
|
|
||||||
// Insignia = insignia,
|
|
||||||
// Level = kp7.InsigniaLevel,
|
|
||||||
// No = profile.InsigniaNo,
|
|
||||||
// Issue = kp7.InsigniaIssue,
|
|
||||||
// VolumeNo = kp7.InsigniaVolumeno.Value.ToString(),
|
|
||||||
// Volume = kp7.InsigniaVolume,
|
|
||||||
// Section = kp7.InsigniaSection,
|
|
||||||
// DateStamp = DateTime.Now,
|
|
||||||
// DateAnnounce = kp7.InsigniaDateannounce.Value,
|
|
||||||
// Page = profile.InsigniaPage,
|
|
||||||
// };
|
|
||||||
|
|
||||||
// return kp7Insignia;
|
|
||||||
// }
|
|
||||||
// catch
|
|
||||||
// {
|
|
||||||
// throw;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// update กพ.7
|
|
||||||
// public async ProfileInsignia UpdateKp7Insignia(Guid id)
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// var item = await _dbContext.Set<ProfileInsignias>().FirstOrDefaultAsync(x => x.Id == id);
|
|
||||||
|
|
||||||
// return item;
|
|
||||||
// }
|
|
||||||
// catch
|
|
||||||
// {
|
|
||||||
// throw;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// เช็คข้อมูลใน kp7insignia
|
||||||
|
// public async ProfileInsignia ListKp7Insignia(string name, string profile, int year)
|
||||||
|
// {
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// var item = await _dbContext.Set<ProfileInsignias>().AsQueryable()
|
||||||
|
// .Include(x => x.Insignia)
|
||||||
|
// .Include(x => x.Profile)
|
||||||
|
// .FirstOrDefault(x => x.Profile.Id == profile &&
|
||||||
|
// x.Year == year &&
|
||||||
|
// x.Insignia.Name.Contains(name));
|
||||||
|
|
||||||
|
// return item;
|
||||||
|
// }
|
||||||
|
// catch
|
||||||
|
// {
|
||||||
|
// throw;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// บันทึกข้อมูลลง กพ.7
|
||||||
|
// public async ProfileInsignia InsertKp7Insignia(InsigniaKp7Item kp7, InsigniaProfile profile)
|
||||||
|
// {
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// var pf = await _dbContext.Set<Profiles>().FirstOrDefault(x => x.Id == profile.FkProfileId);
|
||||||
|
// var insignia = await _dbContext.Set<Insignias>().FirstOrDefault(x => x.Name == profile.InsigniaName);
|
||||||
|
|
||||||
|
// var kp7Insignia = new ProfileInsignia
|
||||||
|
// {
|
||||||
|
// Profile = pf,
|
||||||
|
// Year = DateTime.Now.Year,
|
||||||
|
// DateReceive = kp7.InsigniaDatereceive.Value,
|
||||||
|
// Insignia = insignia,
|
||||||
|
// Level = kp7.InsigniaLevel,
|
||||||
|
// No = profile.InsigniaNo,
|
||||||
|
// Issue = kp7.InsigniaIssue,
|
||||||
|
// VolumeNo = kp7.InsigniaVolumeno.Value.ToString(),
|
||||||
|
// Volume = kp7.InsigniaVolume,
|
||||||
|
// Section = kp7.InsigniaSection,
|
||||||
|
// DateStamp = DateTime.Now,
|
||||||
|
// DateAnnounce = kp7.InsigniaDateannounce.Value,
|
||||||
|
// Page = profile.InsigniaPage,
|
||||||
|
// };
|
||||||
|
|
||||||
|
// return kp7Insignia;
|
||||||
|
// }
|
||||||
|
// catch
|
||||||
|
// {
|
||||||
|
// throw;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// update กพ.7
|
||||||
|
// public async ProfileInsignia UpdateKp7Insignia(Guid id)
|
||||||
|
// {
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// var item = await _dbContext.Set<ProfileInsignias>().FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
|
||||||
|
// return item;
|
||||||
|
// }
|
||||||
|
// catch
|
||||||
|
// {
|
||||||
|
// throw;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using BMA.EHR.Application.Common.Interfaces;
|
using BMA.EHR.Application.Common.Interfaces;
|
||||||
|
using BMA.EHR.Application.Messaging;
|
||||||
using BMA.EHR.Application.Responses;
|
using BMA.EHR.Application.Responses;
|
||||||
using BMA.EHR.Application.Responses.Messages;
|
using BMA.EHR.Application.Responses.Messages;
|
||||||
using BMA.EHR.Domain.Models.HR;
|
using BMA.EHR.Domain.Models.HR;
|
||||||
|
|
@ -17,16 +18,19 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
||||||
|
|
||||||
private readonly IApplicationDBContext _dbContext;
|
private readonly IApplicationDBContext _dbContext;
|
||||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
private readonly EmailSenderService _emailSenderService;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " Constructor and Destuctor "
|
#region " Constructor and Destuctor "
|
||||||
|
|
||||||
public NotificationRepository(IApplicationDBContext dbContext,
|
public NotificationRepository(IApplicationDBContext dbContext,
|
||||||
IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
EmailSenderService emailSenderService,
|
||||||
|
IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
_emailSenderService = emailSenderService;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -130,19 +134,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
||||||
}
|
}
|
||||||
if (IsSendMail == true)
|
if (IsSendMail == true)
|
||||||
{
|
{
|
||||||
// _context.Notifications.Add(new Notification
|
_emailSenderService.SendMail(Subject, Body, "kittapath@frappet.com");
|
||||||
// {
|
|
||||||
// Body = req.Body,
|
|
||||||
// ReceiverUserId = req.ReceiverUserId,
|
|
||||||
// Type = "",
|
|
||||||
// Payload = "",
|
|
||||||
// CreatedUserId = UserId ?? "System Administrator",
|
|
||||||
// CreatedFullName = FullName ?? "",
|
|
||||||
// CreatedAt = DateTime.Now,
|
|
||||||
// LastUpdateFullName = FullName ?? "System Administrator",
|
|
||||||
// LastUpdateUserId = UserId ?? "",
|
|
||||||
// LastUpdatedAt = DateTime.Now,
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
await _dbContext.SaveChangesAsync();
|
await _dbContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
public bool IsApprove { get; set; }
|
public bool IsApprove { get; set; }
|
||||||
public DateTime? RequestDate { get; set; }
|
public DateTime? RequestDate { get; set; }
|
||||||
|
public List<string> MarkALert { get; set; }
|
||||||
public string? RequestNote { get; set; }
|
public string? RequestNote { get; set; }
|
||||||
public string? Reason { get; set; }
|
public string? Reason { get; set; }
|
||||||
public List<InsigniaRequestDoc>? Docs { get; set; }
|
public List<InsigniaRequestDoc>? Docs { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,9 @@ namespace BMA.EHR.Domain.Models.Insignias
|
||||||
[Comment("เหตุผลการได้รับเครื่องราชฯ")]
|
[Comment("เหตุผลการได้รับเครื่องราชฯ")]
|
||||||
public string? Reason { get; set; }
|
public string? Reason { get; set; }
|
||||||
|
|
||||||
|
[Comment("มาร์คแจ้งเตือนความผิด")]
|
||||||
|
public string? MarkALert { get; set; }
|
||||||
|
|
||||||
public Profile Profile { get; set; }
|
public Profile Profile { get; set; }
|
||||||
|
|
||||||
public Insignia RequestInsignia { get; set; }
|
public Insignia RequestInsignia { get; set; }
|
||||||
|
|
|
||||||
16372
BMA.EHR.Infrastructure/Migrations/20230927050934_update table insignianoteprofile add alert.Designer.cs
generated
Normal file
16372
BMA.EHR.Infrastructure/Migrations/20230927050934_update table insignianoteprofile add alert.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,30 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class updatetableinsignianoteprofileaddalert : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "MarkALert",
|
||||||
|
table: "InsigniaRequestProfiles",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "มาร์คแจ้งเตือนความผิด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "MarkALert",
|
||||||
|
table: "InsigniaRequestProfiles");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6004,6 +6004,10 @@ namespace BMA.EHR.Infrastructure.Migrations
|
||||||
.HasColumnOrder(102)
|
.HasColumnOrder(102)
|
||||||
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
|
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
|
||||||
|
|
||||||
|
b.Property<string>("MarkALert")
|
||||||
|
.HasColumnType("longtext")
|
||||||
|
.HasComment("มาร์คแจ้งเตือนความผิด");
|
||||||
|
|
||||||
b.Property<string>("MatchingConditions")
|
b.Property<string>("MatchingConditions")
|
||||||
.HasColumnType("text")
|
.HasColumnType("text")
|
||||||
.HasComment("รายละเอียดเครื่องราชฯที่ขอ");
|
.HasComment("รายละเอียดเครื่องราชฯที่ขอ");
|
||||||
|
|
|
||||||
|
|
@ -866,6 +866,30 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
// }
|
// }
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mark แจ้งเตือนเงื่อนไขได้รับเครื่องราช
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="insigniaRequestProfileId">Id รายชื่อคนที่ยื่นของในรอบ</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPut("alert/{insigniaRequestProfileId:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> MarkAlertProfileInsignia([FromBody] InsigniaMarkAlertRequest req, Guid insigniaRequestProfileId)
|
||||||
|
{
|
||||||
|
var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.Id == insigniaRequestProfileId);
|
||||||
|
if (insigniaRequestProfile == null)
|
||||||
|
return Error(GlobalMessages.InsigniaRequestProfileNotFound);
|
||||||
|
insigniaRequestProfile.MarkALert = JsonConvert.SerializeObject(req.Alert);
|
||||||
|
insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
insigniaRequestProfile.LastUpdateUserId = UserId ?? "";
|
||||||
|
insigniaRequestProfile.LastUpdatedAt = DateTime.Now;
|
||||||
|
_context.SaveChanges();
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ย้ายขอมูลไปเป็น คนที่ไม่ยื่นขอ
|
/// ย้ายขอมูลไปเป็น คนที่ไม่ยื่นขอ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -880,7 +904,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
{
|
{
|
||||||
var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.Id == insigniaRequestProfileId);
|
var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.Id == insigniaRequestProfileId);
|
||||||
if (insigniaRequestProfile == null)
|
if (insigniaRequestProfile == null)
|
||||||
return Error(GlobalMessages.InsigniaPeriodNotFound);
|
return Error(GlobalMessages.InsigniaRequestProfileNotFound);
|
||||||
insigniaRequestProfile.Status = "REJECT";
|
insigniaRequestProfile.Status = "REJECT";
|
||||||
insigniaRequestProfile.ReasonReject = req.Reason;
|
insigniaRequestProfile.ReasonReject = req.Reason;
|
||||||
insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator";
|
insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
|
@ -904,7 +928,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
{
|
{
|
||||||
var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.Id == insigniaRequestProfileId);
|
var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.Id == insigniaRequestProfileId);
|
||||||
if (insigniaRequestProfile == null)
|
if (insigniaRequestProfile == null)
|
||||||
return Error(GlobalMessages.InsigniaPeriodNotFound);
|
return Error(GlobalMessages.InsigniaRequestProfileNotFound);
|
||||||
insigniaRequestProfile.Status = "DELETE";
|
insigniaRequestProfile.Status = "DELETE";
|
||||||
insigniaRequestProfile.ReasonReject = req.Reason;
|
insigniaRequestProfile.ReasonReject = req.Reason;
|
||||||
insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator";
|
insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
|
@ -2216,12 +2240,16 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
[HttpPut("note/return/{insigniaNoteProfileId:length(36)}"), DisableRequestSizeLimit]
|
[HttpPut("note/return/{insigniaNoteProfileId:length(36)}"), DisableRequestSizeLimit]
|
||||||
public async Task<ActionResult<ResponseObject>> UpdateReturnNoteInsignia([FromForm] InsigniaNoteReturnRequest req, Guid insigniaNoteProfileId)
|
public async Task<ActionResult<ResponseObject>> UpdateReturnNoteInsignia([FromForm] InsigniaNoteReturnRequest req, Guid insigniaNoteProfileId)
|
||||||
{
|
{
|
||||||
var insigniaNoteProfile = await _context.InsigniaNoteProfiles.Where(x => x.Id == insigniaNoteProfileId).FirstOrDefaultAsync();
|
var insigniaNoteProfile = await _context.InsigniaNoteProfiles.Include(x => x.DocReturnInsignia).Where(x => x.Id == insigniaNoteProfileId).FirstOrDefaultAsync();
|
||||||
if (insigniaNoteProfile == null)
|
if (insigniaNoteProfile == null)
|
||||||
return Error(GlobalMessages.InsigniaRequestProfileNotFound, 404);
|
return Error(GlobalMessages.InsigniaRequestProfileNotFound, 404);
|
||||||
|
|
||||||
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
||||||
{
|
{
|
||||||
|
if (insigniaNoteProfile.DocReturnInsignia != null)
|
||||||
|
{
|
||||||
|
await _documentService.DeleteFileAsync(insigniaNoteProfile.DocReturnInsignia.Id);
|
||||||
|
}
|
||||||
var file = Request.Form.Files[0];
|
var file = Request.Form.Files[0];
|
||||||
var fileExtension = Path.GetExtension(file.FileName);
|
var fileExtension = Path.GetExtension(file.FileName);
|
||||||
|
|
||||||
|
|
@ -2250,12 +2278,17 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
[HttpPut("note/receive/{insigniaNoteProfileId:length(36)}"), DisableRequestSizeLimit]
|
[HttpPut("note/receive/{insigniaNoteProfileId:length(36)}"), DisableRequestSizeLimit]
|
||||||
public async Task<ActionResult<ResponseObject>> UpdateReceiveNoteInsignia([FromForm] InsigniaNoteReturnRequest req, Guid insigniaNoteProfileId)
|
public async Task<ActionResult<ResponseObject>> UpdateReceiveNoteInsignia([FromForm] InsigniaNoteReturnRequest req, Guid insigniaNoteProfileId)
|
||||||
{
|
{
|
||||||
var insigniaNoteProfile = await _context.InsigniaNoteProfiles.Where(x => x.Id == insigniaNoteProfileId).FirstOrDefaultAsync();
|
var insigniaNoteProfile = await _context.InsigniaNoteProfiles.Include(x => x.DocReceiveInsignia).Where(x => x.Id == insigniaNoteProfileId).FirstOrDefaultAsync();
|
||||||
if (insigniaNoteProfile == null)
|
if (insigniaNoteProfile == null)
|
||||||
return Error(GlobalMessages.InsigniaRequestProfileNotFound, 404);
|
return Error(GlobalMessages.InsigniaRequestProfileNotFound, 404);
|
||||||
|
|
||||||
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
||||||
{
|
{
|
||||||
|
if (insigniaNoteProfile.DocReceiveInsignia != null)
|
||||||
|
{
|
||||||
|
await _documentService.DeleteFileAsync(insigniaNoteProfile.DocReceiveInsignia.Id);
|
||||||
|
}
|
||||||
|
|
||||||
var file = Request.Form.Files[0];
|
var file = Request.Form.Files[0];
|
||||||
var fileExtension = Path.GetExtension(file.FileName);
|
var fileExtension = Path.GetExtension(file.FileName);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Insignia.Service.Requests
|
||||||
|
{
|
||||||
|
public class InsigniaMarkAlertRequest
|
||||||
|
{
|
||||||
|
public string[] Alert { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue