รับโอนอัพรูป
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.Organizations;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
using BMA.EHR.Domain.Models.Documents;
|
||||
|
||||
namespace BMA.EHR.Domain.Models.Placement
|
||||
{
|
||||
|
|
@ -11,6 +12,8 @@ namespace BMA.EHR.Domain.Models.Placement
|
|||
{
|
||||
[Required, Comment("Id User")]
|
||||
public Profile Profile { get; set; }
|
||||
[Comment("Fk Table Document")]
|
||||
public Document? Avatar { get; set; }
|
||||
[Required, MaxLength(20), Comment("เลขประจำตัวประชาชน")]
|
||||
public string CitizenId { get; set; }
|
||||
[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")
|
||||
.HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน");
|
||||
|
||||
b.Property<Guid?>("AvatarId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("BloodGroupId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
|
|
@ -11870,6 +11873,8 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AvatarId");
|
||||
|
||||
b.HasIndex("BloodGroupId");
|
||||
|
||||
b.HasIndex("GenderId");
|
||||
|
|
@ -15190,6 +15195,10 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
|
||||
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")
|
||||
.WithMany()
|
||||
.HasForeignKey("BloodGroupId");
|
||||
|
|
@ -15246,6 +15255,8 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
.WithMany()
|
||||
.HasForeignKey("ReligionId");
|
||||
|
||||
b.Navigation("Avatar");
|
||||
|
||||
b.Navigation("BloodGroup");
|
||||
|
||||
b.Navigation("Gender");
|
||||
|
|
|
|||
|
|
@ -153,22 +153,23 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
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();
|
||||
if (data == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
var placementReceiveDocs = new List<dynamic>();
|
||||
foreach (var doc in data.PlacementReceiveDocs)
|
||||
{
|
||||
var _doc = new
|
||||
{
|
||||
doc.FileName,
|
||||
PathName = await _documentService.ImagesPath(doc.Id)
|
||||
};
|
||||
placementReceiveDocs.Add(_doc);
|
||||
}
|
||||
// var placementReceiveDocs = new List<dynamic>();
|
||||
// foreach (var doc in data.PlacementReceiveDocs)
|
||||
// {
|
||||
// var _doc = new
|
||||
// {
|
||||
// doc.FileName,
|
||||
// PathName = await _documentService.ImagesPath(doc.Id)
|
||||
// };
|
||||
// placementReceiveDocs.Add(_doc);
|
||||
// }
|
||||
var _data = new
|
||||
{
|
||||
data.Id,
|
||||
|
|
@ -204,7 +205,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
data.PositionLevelOld,
|
||||
data.PositionNumberOld,
|
||||
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);
|
||||
|
|
@ -269,30 +271,31 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
await _context.SaveChangesAsync();
|
||||
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 doc = await _documentService.UploadFileAsync(file, file.FileName);
|
||||
var _doc = await _context.Documents.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||
if (_doc != null)
|
||||
{
|
||||
var placementReceiveDoc = new PlacementReceiveDoc
|
||||
{
|
||||
PlacementReceive = placementReceive,
|
||||
Document = _doc,
|
||||
CreatedUserId = FullName ?? "",
|
||||
CreatedFullName = UserId ?? "System Administrator",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
await _context.PlacementReceiveDocs.AddAsync(placementReceiveDoc);
|
||||
|
||||
}
|
||||
// var placementReceiveDoc = new PlacementReceiveDoc
|
||||
// {
|
||||
// PlacementReceive = placementReceive,
|
||||
// Document = _doc,
|
||||
// CreatedUserId = FullName ?? "",
|
||||
// CreatedFullName = UserId ?? "System Administrator",
|
||||
// CreatedAt = DateTime.Now,
|
||||
// LastUpdateFullName = FullName ?? "System Administrator",
|
||||
// LastUpdateUserId = UserId ?? "",
|
||||
// LastUpdatedAt = DateTime.Now,
|
||||
// };
|
||||
// await _context.PlacementReceiveDocs.AddAsync(placementReceiveDoc);
|
||||
placementReceive.Avatar = _doc;
|
||||
}
|
||||
// }
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue