fix bug GetList คำสั่ง
เพิ่ม api แก้ไขคำสั่ง
This commit is contained in:
parent
ab7135fcbf
commit
680bfba81e
4 changed files with 255 additions and 9 deletions
|
|
@ -1,8 +1,10 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Domain.Models.Commands.Core;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Organizations;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Command = BMA.EHR.Domain.Models.Commands.Core.Command;
|
||||
|
|
@ -44,6 +46,15 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
public override async Task<IReadOnlyList<Command>> GetAllAsync()
|
||||
{
|
||||
return await _dbContext.Set<Command>()
|
||||
.Include(x => x.Placement)
|
||||
.Include(x => x.CommandType)
|
||||
.Include(x => x.CommandStatus)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public override async Task<Command> AddAsync(Command command)
|
||||
{
|
||||
var status = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(c => c.Sequence == 1);
|
||||
|
|
@ -335,6 +346,54 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
|
||||
#region " Documents "
|
||||
|
||||
public async Task<List<CommandDocument>> GetExistDocument(Guid id, string category)
|
||||
{
|
||||
try
|
||||
{
|
||||
var command = await _dbContext.Set<Command>()
|
||||
.Include(x => x.Documents)
|
||||
.ThenInclude(x => x.Document)
|
||||
.FirstOrDefaultAsync(c => c.Id == id);
|
||||
if (command == null)
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
|
||||
// insert new record to comand Document
|
||||
var exist = command.Documents.Where(x => x.Category == category).ToList();
|
||||
|
||||
return exist;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UploadDocument(Guid id, string category, CommandDocument document)
|
||||
{
|
||||
try
|
||||
{
|
||||
var command = await _dbContext.Set<Command>().Include(x => x.Documents).FirstOrDefaultAsync(c => c.Id == id);
|
||||
if (command == null)
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
|
||||
// insert new record to comand Document
|
||||
var exist = command.Documents.Where(x => x.Category == category).ToList();
|
||||
if (exist.Any())
|
||||
{
|
||||
_dbContext.Set<CommandDocument>().RemoveRange(exist);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
// insert new Record
|
||||
command.Documents.Add(document);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<CommandDocument>> GetCommandDocumentAsync(Guid id)
|
||||
{
|
||||
try
|
||||
|
|
@ -407,6 +466,36 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
|
||||
#endregion
|
||||
|
||||
#region " Change Detail Sequence "
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Placement "
|
||||
|
||||
public async Task<List<PositionPath>> GetPlacementPositionPath(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _dbContext.Set<PlacementProfile>()
|
||||
.Include(x => x.PositionPath)
|
||||
.Include(x => x.Placement)
|
||||
.Where(x => x.Placement!.Id == id)
|
||||
.Where(x => x.PositionPath != null)
|
||||
.Select(x => x.PositionPath)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
|
||||
return data!;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public async Task UpdateCommandInfo(Guid id, string orderNo, string orderYear, DateTime signDate)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue