รับโอนอัพรูป
This commit is contained in:
parent
97abafe821
commit
0e0b10a82d
5 changed files with 16064 additions and 34 deletions
|
|
@ -4,6 +4,7 @@ using BMA.EHR.Domain.Models.Base;
|
||||||
using BMA.EHR.Domain.Models.MetaData;
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
using BMA.EHR.Domain.Models.Organizations;
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
using BMA.EHR.Domain.Models.HR;
|
using BMA.EHR.Domain.Models.HR;
|
||||||
|
using BMA.EHR.Domain.Models.Documents;
|
||||||
|
|
||||||
namespace BMA.EHR.Domain.Models.Placement
|
namespace BMA.EHR.Domain.Models.Placement
|
||||||
{
|
{
|
||||||
|
|
@ -11,6 +12,8 @@ namespace BMA.EHR.Domain.Models.Placement
|
||||||
{
|
{
|
||||||
[Required, Comment("Id User")]
|
[Required, Comment("Id User")]
|
||||||
public Profile Profile { get; set; }
|
public Profile Profile { get; set; }
|
||||||
|
[Comment("Fk Table Document")]
|
||||||
|
public Document? Avatar { get; set; }
|
||||||
[Required, MaxLength(20), Comment("เลขประจำตัวประชาชน")]
|
[Required, MaxLength(20), Comment("เลขประจำตัวประชาชน")]
|
||||||
public string CitizenId { get; set; }
|
public string CitizenId { get; set; }
|
||||||
[Required, Comment("คำนำหน้า")]
|
[Required, Comment("คำนำหน้า")]
|
||||||
|
|
|
||||||
15963
BMA.EHR.Infrastructure/Migrations/20230829102608_update table placement add avatar.Designer.cs
generated
Normal file
15963
BMA.EHR.Infrastructure/Migrations/20230829102608_update table placement add avatar.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,50 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class updatetableplacementaddavatar : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "AvatarId",
|
||||||
|
table: "PlacementReceives",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementReceives_AvatarId",
|
||||||
|
table: "PlacementReceives",
|
||||||
|
column: "AvatarId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_PlacementReceives_Documents_AvatarId",
|
||||||
|
table: "PlacementReceives",
|
||||||
|
column: "AvatarId",
|
||||||
|
principalTable: "Documents",
|
||||||
|
principalColumn: "Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_PlacementReceives_Documents_AvatarId",
|
||||||
|
table: "PlacementReceives");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_PlacementReceives_AvatarId",
|
||||||
|
table: "PlacementReceives");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "AvatarId",
|
||||||
|
table: "PlacementReceives");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11718,6 +11718,9 @@ namespace BMA.EHR.Infrastructure.Migrations
|
||||||
.HasColumnType("double")
|
.HasColumnType("double")
|
||||||
.HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน");
|
.HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน");
|
||||||
|
|
||||||
|
b.Property<Guid?>("AvatarId")
|
||||||
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
b.Property<Guid?>("BloodGroupId")
|
b.Property<Guid?>("BloodGroupId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
|
|
@ -11870,6 +11873,8 @@ namespace BMA.EHR.Infrastructure.Migrations
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AvatarId");
|
||||||
|
|
||||||
b.HasIndex("BloodGroupId");
|
b.HasIndex("BloodGroupId");
|
||||||
|
|
||||||
b.HasIndex("GenderId");
|
b.HasIndex("GenderId");
|
||||||
|
|
@ -15190,6 +15195,10 @@ namespace BMA.EHR.Infrastructure.Migrations
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementReceive", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementReceive", b =>
|
||||||
{
|
{
|
||||||
|
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Avatar")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("AvatarId");
|
||||||
|
|
||||||
b.HasOne("BMA.EHR.Domain.Models.MetaData.BloodGroup", "BloodGroup")
|
b.HasOne("BMA.EHR.Domain.Models.MetaData.BloodGroup", "BloodGroup")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("BloodGroupId");
|
.HasForeignKey("BloodGroupId");
|
||||||
|
|
@ -15246,6 +15255,8 @@ namespace BMA.EHR.Infrastructure.Migrations
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("ReligionId");
|
.HasForeignKey("ReligionId");
|
||||||
|
|
||||||
|
b.Navigation("Avatar");
|
||||||
|
|
||||||
b.Navigation("BloodGroup");
|
b.Navigation("BloodGroup");
|
||||||
|
|
||||||
b.Navigation("Gender");
|
b.Navigation("Gender");
|
||||||
|
|
|
||||||
|
|
@ -153,22 +153,23 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
p.PositionLevelOld,
|
p.PositionLevelOld,
|
||||||
p.PositionNumberOld,
|
p.PositionNumberOld,
|
||||||
p.OrganizationPositionOld,
|
p.OrganizationPositionOld,
|
||||||
PlacementReceiveDocs = p.PlacementReceiveDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
Avatar = p.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Avatar.Id,
|
||||||
|
// PlacementReceiveDocs = p.PlacementReceiveDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
if (data == null)
|
if (data == null)
|
||||||
return Error(GlobalMessages.DataNotFound, 404);
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
var placementReceiveDocs = new List<dynamic>();
|
// var placementReceiveDocs = new List<dynamic>();
|
||||||
foreach (var doc in data.PlacementReceiveDocs)
|
// foreach (var doc in data.PlacementReceiveDocs)
|
||||||
{
|
// {
|
||||||
var _doc = new
|
// var _doc = new
|
||||||
{
|
// {
|
||||||
doc.FileName,
|
// doc.FileName,
|
||||||
PathName = await _documentService.ImagesPath(doc.Id)
|
// PathName = await _documentService.ImagesPath(doc.Id)
|
||||||
};
|
// };
|
||||||
placementReceiveDocs.Add(_doc);
|
// placementReceiveDocs.Add(_doc);
|
||||||
}
|
// }
|
||||||
var _data = new
|
var _data = new
|
||||||
{
|
{
|
||||||
data.Id,
|
data.Id,
|
||||||
|
|
@ -204,7 +205,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
data.PositionLevelOld,
|
data.PositionLevelOld,
|
||||||
data.PositionNumberOld,
|
data.PositionNumberOld,
|
||||||
data.OrganizationPositionOld,
|
data.OrganizationPositionOld,
|
||||||
Docs = placementReceiveDocs,
|
Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
|
||||||
|
// Docs = placementReceiveDocs,
|
||||||
};
|
};
|
||||||
|
|
||||||
return Success(_data);
|
return Success(_data);
|
||||||
|
|
@ -269,30 +271,31 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
||||||
{
|
{
|
||||||
foreach (var file in Request.Form.Files)
|
// foreach (var file in Request.Form.Files)
|
||||||
|
// {
|
||||||
|
var file = Request.Form.Files[0];
|
||||||
|
var fileExtension = Path.GetExtension(file.FileName);
|
||||||
|
|
||||||
|
var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
||||||
|
var _doc = await _context.Documents.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||||
|
if (_doc != null)
|
||||||
{
|
{
|
||||||
var fileExtension = Path.GetExtension(file.FileName);
|
// var placementReceiveDoc = new PlacementReceiveDoc
|
||||||
|
// {
|
||||||
var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
// PlacementReceive = placementReceive,
|
||||||
var _doc = await _context.Documents.AsQueryable()
|
// Document = _doc,
|
||||||
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
// CreatedUserId = FullName ?? "",
|
||||||
if (_doc != null)
|
// CreatedFullName = UserId ?? "System Administrator",
|
||||||
{
|
// CreatedAt = DateTime.Now,
|
||||||
var placementReceiveDoc = new PlacementReceiveDoc
|
// LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
{
|
// LastUpdateUserId = UserId ?? "",
|
||||||
PlacementReceive = placementReceive,
|
// LastUpdatedAt = DateTime.Now,
|
||||||
Document = _doc,
|
// };
|
||||||
CreatedUserId = FullName ?? "",
|
// await _context.PlacementReceiveDocs.AddAsync(placementReceiveDoc);
|
||||||
CreatedFullName = UserId ?? "System Administrator",
|
placementReceive.Avatar = _doc;
|
||||||
CreatedAt = DateTime.Now,
|
|
||||||
LastUpdateFullName = FullName ?? "System Administrator",
|
|
||||||
LastUpdateUserId = UserId ?? "",
|
|
||||||
LastUpdatedAt = DateTime.Now,
|
|
||||||
};
|
|
||||||
await _context.PlacementReceiveDocs.AddAsync(placementReceiveDoc);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue