fix ยืมคืน
This commit is contained in:
parent
0234925827
commit
84bb010535
1 changed files with 97 additions and 10 deletions
|
|
@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Export.ToDataTable;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
|
||||
namespace BMA.EHR.Insignia.Service.Controllers
|
||||
|
|
@ -437,6 +438,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
//var _organization = await _context.Organizations.AsQueryable()
|
||||
// .FirstOrDefaultAsync(x => x.Id == insigniaNoteProfile.Profile.OcId);
|
||||
|
||||
//TODO : Hardcode OCId
|
||||
if (req.BorrowOrganizationId == null) req.BorrowOrganizationId = Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3");
|
||||
|
||||
var organization = _userProfileRepository.GetOc(req.BorrowOrganizationId.Value, 0, AccessToken);
|
||||
//if (organization == null)
|
||||
// return Error(GlobalMessages.OrganizationNotFound);
|
||||
|
|
@ -548,30 +552,27 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
.FirstOrDefaultAsync(x => x.Id == insigniaTypeId);
|
||||
if (insigniaType == null)
|
||||
return Error(GlobalMessages.InsigniaTypeNotFound);
|
||||
var data = await _context.InsigniaManageProfiles.AsQueryable()
|
||||
|
||||
|
||||
var rawData = await _context.InsigniaManageProfiles.AsQueryable()
|
||||
.Where(x => x.InsigniaNoteProfile.RequestInsignia.InsigniaType == insigniaType)
|
||||
.Where(x => year == 0 ? x.Id != null : x.InsigniaManageOrganiation.InsigniaManage.Year == year)
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Select(p => new
|
||||
{
|
||||
Id = p.Id,
|
||||
BorrowOrganization = p.BorrowOrganizationId == null ? null : _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken),
|
||||
ReturnOrganization = p.ReturnOrganizationId == null ? null : _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken),
|
||||
Profile = p.InsigniaNoteProfile.ProfileId == null ? null : _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken),
|
||||
|
||||
Status = p.Status,
|
||||
BorrowOrganization = _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken) == null ? null : _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken).Root,
|
||||
BorrowOrganizationId = _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken) == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken).RootId,
|
||||
BorrowDate = p.BorrowDate,
|
||||
ReturnDate = p.ReturnDate,
|
||||
ReturnOrganization = _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken) == null ? null : _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken).Root,
|
||||
ReturnOrganizationId = _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken) == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken).RootId,
|
||||
ReturnReason = p.ReturnReason,
|
||||
LastUpdatedAt = p.LastUpdatedAt,
|
||||
CreatedAt = p.CreatedAt,
|
||||
|
||||
InsigniaNoteProfileId = p.InsigniaNoteProfile.Id,
|
||||
Prefix = _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).Prefix,
|
||||
Position = _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).Position,
|
||||
_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).CitizenId,
|
||||
_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).ProfileType,
|
||||
FullName = $"{_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).Prefix}{_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).FirstName} {_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).LastName}",
|
||||
RequestInsignia = p.InsigniaNoteProfile.RequestInsignia == null ? null : p.InsigniaNoteProfile.RequestInsignia.Name,
|
||||
RequestInsigniaId = p.InsigniaNoteProfile.RequestInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.InsigniaNoteProfile.RequestInsignia.Id,
|
||||
RequestInsigniaShortName = p.InsigniaNoteProfile.RequestInsignia == null ? null : p.InsigniaNoteProfile.RequestInsignia.ShortName,
|
||||
|
|
@ -592,6 +593,92 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
p.InsigniaNoteProfile.Salary,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var data = rawData
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.Status,
|
||||
BorrowOrganization = p.BorrowOrganization == null ? "" : p.BorrowOrganization.Root,
|
||||
BorrowOrganizationId = p.BorrowOrganization == null ? Guid.Empty : p.BorrowOrganization.RootId,
|
||||
p.BorrowDate,
|
||||
p.ReturnDate,
|
||||
ReturnOrganization = p.ReturnOrganization == null ? "" : p.ReturnOrganization.Root,
|
||||
ReturnOrganizationId = p.ReturnOrganization == null ? Guid.Empty : p.ReturnOrganization.RootId,
|
||||
p.ReturnReason,
|
||||
p.LastUpdatedAt,
|
||||
p.CreatedAt,
|
||||
p.InsigniaNoteProfileId,
|
||||
Prefix = p.Profile == null ? "" : p.Profile.Prefix,
|
||||
Position = p.Profile == null ? "" : p.Profile.Position,
|
||||
FullName = p.Profile == null ? "" : $"{p.Profile.Prefix}{p.Profile.FirstName} {p.Profile.LastName}",
|
||||
p.RequestInsignia,
|
||||
p.RequestInsigniaId,
|
||||
p.RequestInsigniaShortName,
|
||||
p.DateReceive,
|
||||
p.OrganizationOrganizationSend,
|
||||
p.OrganizationOrganizationReceive,
|
||||
p.InsigniaNoteProfileStatus,
|
||||
p.Issue,
|
||||
p.Date,
|
||||
p.VolumeNo,
|
||||
p.Section,
|
||||
p.Page,
|
||||
p.No,
|
||||
p.DatePayment,
|
||||
p.TypePayment,
|
||||
p.Address,
|
||||
p.Number,
|
||||
p.Salary,
|
||||
|
||||
})
|
||||
.ToList();
|
||||
|
||||
//var data = await _context.InsigniaManageProfiles.AsQueryable()
|
||||
// .Where(x => x.InsigniaNoteProfile.RequestInsignia.InsigniaType == insigniaType)
|
||||
// .Where(x => year == 0 ? x.Id != null : x.InsigniaManageOrganiation.InsigniaManage.Year == year)
|
||||
// .OrderByDescending(x => x.CreatedAt)
|
||||
// .Select(p => new
|
||||
// {
|
||||
// Id = p.Id,
|
||||
// Status = p.Status,
|
||||
// BorrowOrganization = _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken) == null ? null : _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken).Root,
|
||||
// BorrowOrganizationId = _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken) == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken).RootId,
|
||||
// BorrowDate = p.BorrowDate,
|
||||
// ReturnDate = p.ReturnDate,
|
||||
// ReturnOrganization = _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken) == null ? null : _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken).Root,
|
||||
// ReturnOrganizationId = _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken) == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken).RootId,
|
||||
// ReturnReason = p.ReturnReason,
|
||||
// LastUpdatedAt = p.LastUpdatedAt,
|
||||
// CreatedAt = p.CreatedAt,
|
||||
|
||||
// InsigniaNoteProfileId = p.InsigniaNoteProfile.Id,
|
||||
// Prefix = _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).Prefix,
|
||||
// Position = _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).Position,
|
||||
// _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).CitizenId,
|
||||
// _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).ProfileType,
|
||||
// FullName = $"{_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).Prefix}{_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).FirstName} {_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).LastName}",
|
||||
// RequestInsignia = p.InsigniaNoteProfile.RequestInsignia == null ? null : p.InsigniaNoteProfile.RequestInsignia.Name,
|
||||
// RequestInsigniaId = p.InsigniaNoteProfile.RequestInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.InsigniaNoteProfile.RequestInsignia.Id,
|
||||
// RequestInsigniaShortName = p.InsigniaNoteProfile.RequestInsignia == null ? null : p.InsigniaNoteProfile.RequestInsignia.ShortName,
|
||||
// p.InsigniaNoteProfile.DateReceive,
|
||||
// p.InsigniaNoteProfile.OrganizationOrganizationSend,
|
||||
// p.InsigniaNoteProfile.OrganizationOrganizationReceive,
|
||||
// InsigniaNoteProfileStatus = p.InsigniaNoteProfile.Status,
|
||||
// p.InsigniaNoteProfile.Issue,
|
||||
// p.InsigniaNoteProfile.Date,
|
||||
// p.InsigniaNoteProfile.VolumeNo,
|
||||
// p.InsigniaNoteProfile.Section,
|
||||
// p.InsigniaNoteProfile.Page,
|
||||
// p.InsigniaNoteProfile.No,
|
||||
// p.InsigniaNoteProfile.DatePayment,
|
||||
// p.InsigniaNoteProfile.TypePayment,
|
||||
// p.InsigniaNoteProfile.Address,
|
||||
// p.InsigniaNoteProfile.Number,
|
||||
// p.InsigniaNoteProfile.Salary,
|
||||
// })
|
||||
// .ToListAsync();
|
||||
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue