บันทึกข้อมูลรับโอน
This commit is contained in:
parent
19803fd523
commit
dec96d2bd3
8 changed files with 16467 additions and 60 deletions
|
|
@ -6,7 +6,7 @@ namespace BMA.EHR.Application.Requests
|
|||
public class InsigniaReturnRequest
|
||||
{
|
||||
public DateTime ReturnDate { get; set; }
|
||||
public Guid ReturnOrganizationId { get; set; }
|
||||
public Guid? ReturnOrganizationId { get; set; }
|
||||
public string ReturnReason { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ namespace BMA.EHR.Domain.Models.Placement
|
|||
{
|
||||
public class PlacementReceive : EntityBase
|
||||
{
|
||||
[Required, Comment("Id User")]
|
||||
public Profile Profile { get; set; }
|
||||
// [Required, Comment("Id User")]
|
||||
// public Profile Profile { get; set; }
|
||||
[Comment("Fk Table Document")]
|
||||
public Document? Avatar { get; set; }
|
||||
[Required, MaxLength(20), Comment("เลขประจำตัวประชาชน")]
|
||||
|
|
|
|||
16368
BMA.EHR.Infrastructure/Migrations/20230926114025_update table PlacementReceives remove profile.Designer.cs
generated
Normal file
16368
BMA.EHR.Infrastructure/Migrations/20230926114025_update table PlacementReceives remove profile.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class updatetablePlacementReceivesremoveprofile : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_PlacementReceives_Profiles_ProfileId",
|
||||
table: "PlacementReceives");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_PlacementReceives_ProfileId",
|
||||
table: "PlacementReceives");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ProfileId",
|
||||
table: "PlacementReceives");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "ProfileId",
|
||||
table: "PlacementReceives",
|
||||
type: "char(36)",
|
||||
nullable: false,
|
||||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
|
||||
collation: "ascii_general_ci");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PlacementReceives_ProfileId",
|
||||
table: "PlacementReceives",
|
||||
column: "ProfileId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_PlacementReceives_Profiles_ProfileId",
|
||||
table: "PlacementReceives",
|
||||
column: "ProfileId",
|
||||
principalTable: "Profiles",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11933,9 +11933,6 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.Property<Guid>("PrefixId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ProfileId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Race")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)")
|
||||
|
|
@ -11989,8 +11986,6 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
|
||||
b.HasIndex("PrefixId");
|
||||
|
||||
b.HasIndex("ProfileId");
|
||||
|
||||
b.HasIndex("RelationshipId");
|
||||
|
||||
b.HasIndex("ReligionId");
|
||||
|
|
@ -15623,12 +15618,6 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProfileId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BMA.EHR.Domain.Models.MetaData.Relationship", "Relationship")
|
||||
.WithMany()
|
||||
.HasForeignKey("RelationshipId");
|
||||
|
|
@ -15659,8 +15648,6 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
|
||||
b.Navigation("Prefix");
|
||||
|
||||
b.Navigation("Profile");
|
||||
|
||||
b.Navigation("Relationship");
|
||||
|
||||
b.Navigation("Religion");
|
||||
|
|
|
|||
|
|
@ -492,19 +492,19 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
|
||||
uppdated.Status = true;
|
||||
uppdated.ReturnDate = req.ReturnDate;
|
||||
if (req.ReturnOrganizationId == Guid.Parse("00000000-0000-0000-0000-000000000000"))
|
||||
{
|
||||
uppdated.ReturnOrganization = uppdated.BorrowOrganization;
|
||||
}
|
||||
else
|
||||
{
|
||||
var organization = await _context.Organizations.AsQueryable()
|
||||
.Include(x => x.OrganizationOrganization)
|
||||
.FirstOrDefaultAsync(x => x.Id == req.ReturnOrganizationId);
|
||||
if (organization == null)
|
||||
return Error(GlobalMessages.OrganizationNotFound);
|
||||
uppdated.ReturnOrganization = organization.OrganizationOrganization;
|
||||
}
|
||||
// if (req.ReturnOrganizationId == Guid.Parse("00000000-0000-0000-0000-000000000000"))
|
||||
// {
|
||||
uppdated.ReturnOrganization = uppdated.BorrowOrganization;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var organization = await _context.Organizations.AsQueryable()
|
||||
// .Include(x => x.OrganizationOrganization)
|
||||
// .FirstOrDefaultAsync(x => x.Id == req.ReturnOrganizationId);
|
||||
// if (organization == null)
|
||||
// return Error(GlobalMessages.OrganizationNotFound);
|
||||
// uppdated.ReturnOrganization = organization.OrganizationOrganization;
|
||||
// }
|
||||
uppdated.ReturnReason = req.ReturnReason;
|
||||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
uppdated.LastUpdateUserId = UserId ?? "";
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
ProfileId = p.Profile.Id,
|
||||
// ProfileId = p.Profile.Id,
|
||||
p.CitizenId,
|
||||
Prefix = p.Prefix.Name,
|
||||
PrefixId = p.Prefix.Id,
|
||||
|
|
@ -177,7 +177,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
var _data = new
|
||||
{
|
||||
data.Id,
|
||||
data.ProfileId,
|
||||
// data.ProfileId,
|
||||
data.CitizenId,
|
||||
data.Prefix,
|
||||
data.PrefixId,
|
||||
|
|
@ -227,42 +227,25 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
[HttpPost()]
|
||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementReceiveRequest req)
|
||||
{
|
||||
var profile = await _context.Profiles
|
||||
.Include(x => x.PositionLevel)
|
||||
.Include(x => x.PositionType)
|
||||
.Include(x => x.PosNo)
|
||||
.Include(x => x.Salaries)
|
||||
.Include(x => x.Educations)
|
||||
.Include(x => x.Position)
|
||||
.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
var prefix = await _context.Prefixes.FindAsync(req.Prefix);
|
||||
if (prefix == null)
|
||||
return Error(GlobalMessages.PrefixNotFound, 404);
|
||||
|
||||
var placementReceive = new PlacementReceive
|
||||
{
|
||||
Profile = profile,
|
||||
// Profile = profile,
|
||||
CitizenId = req.CitizenId,
|
||||
Prefix = prefix,
|
||||
Firstname = req.Firstname,
|
||||
Lastname = req.Lastname,
|
||||
DateOfBirth = req.DateOfBirth,
|
||||
Gender = await _context.Genders.FindAsync(req.Gender),
|
||||
DateOfBirth = req.BirthDate,
|
||||
Gender = await _context.Genders.FindAsync(req.GenderId),
|
||||
Nationality = req.Nationality,
|
||||
Race = req.Race,
|
||||
Religion = await _context.Religions.FindAsync(req.Religion),
|
||||
BloodGroup = await _context.BloodGroups.FindAsync(req.BloodGroup),
|
||||
Relationship = await _context.Relationships.FindAsync(req.Relationship),
|
||||
Religion = await _context.Religions.FindAsync(req.ReligionId),
|
||||
BloodGroup = await _context.BloodGroups.FindAsync(req.BloodGroupId),
|
||||
Relationship = await _context.Relationships.FindAsync(req.RelationshipId),
|
||||
TelephoneNumber = req.TelephoneNumber,
|
||||
EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}",
|
||||
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
||||
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
|
||||
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
|
||||
Status = "WAITTING",
|
||||
CreatedUserId = UserId ?? "System Administrator",
|
||||
CreatedFullName = FullName ?? "",
|
||||
|
|
@ -271,6 +254,24 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
var profile = await _context.Profiles
|
||||
.Include(x => x.PositionLevel)
|
||||
.Include(x => x.PositionType)
|
||||
.Include(x => x.PosNo)
|
||||
.Include(x => x.Salaries)
|
||||
.Include(x => x.Educations)
|
||||
.Include(x => x.Position)
|
||||
.FirstOrDefaultAsync(x => x.CitizenId == req.CitizenId);
|
||||
if (profile != null)
|
||||
{
|
||||
placementReceive.EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}";
|
||||
placementReceive.AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount;
|
||||
placementReceive.PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name;
|
||||
placementReceive.PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name;
|
||||
placementReceive.PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name;
|
||||
placementReceive.OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}";
|
||||
}
|
||||
|
||||
await _context.PlacementReceives.AddAsync(placementReceive);
|
||||
await _context.SaveChangesAsync();
|
||||
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
||||
|
|
@ -463,7 +464,6 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
if (uppdated == null)
|
||||
return Error(GlobalMessages.PlacementReceiveNotFound, 404);
|
||||
|
||||
|
||||
if (req.PrefixId != null)
|
||||
{
|
||||
var save = await _context.Prefixes.FindAsync(req.PrefixId);
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ namespace BMA.EHR.Placement.Service.Requests
|
|||
public Guid Prefix { get; set; }
|
||||
public string Firstname { get; set; }
|
||||
public string Lastname { get; set; }
|
||||
public DateTime DateOfBirth { get; set; }
|
||||
public Guid? Gender { get; set; }
|
||||
public DateTime BirthDate { get; set; }
|
||||
public Guid? GenderId { get; set; }
|
||||
public string? Nationality { get; set; }
|
||||
public string? Race { get; set; }
|
||||
public Guid? Religion { get; set; }
|
||||
public Guid? BloodGroup { get; set; }
|
||||
public Guid? Relationship { get; set; }
|
||||
public Guid? ReligionId { get; set; }
|
||||
public Guid? BloodGroupId { get; set; }
|
||||
public Guid? RelationshipId { get; set; }
|
||||
public string? TelephoneNumber { get; set; }
|
||||
public List<FormFile>? File { get; set; }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue