fix bug swap record
This commit is contained in:
parent
e5699ea046
commit
dbdd4a7be4
1 changed files with 8 additions and 2 deletions
|
|
@ -614,12 +614,14 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var current = await _dbContext.Set<CommandReceiver>()
|
var current = await _dbContext.Set<CommandReceiver>()
|
||||||
|
.Include(c => c.Command)
|
||||||
.FirstOrDefaultAsync(x => x.Id == personalId);
|
.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||||
|
|
||||||
if (current == null)
|
if (current == null)
|
||||||
throw new Exception(GlobalMessages.DataNotFound);
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
|
|
||||||
var currentSeq = current.Sequence;
|
var currentSeq = current.Sequence;
|
||||||
|
var commandID = current.Command!.Id;
|
||||||
|
|
||||||
switch (direction.Trim().ToLower())
|
switch (direction.Trim().ToLower())
|
||||||
{
|
{
|
||||||
|
|
@ -627,8 +629,10 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
{
|
{
|
||||||
// get prev record
|
// get prev record
|
||||||
var prev = await _dbContext.Set<CommandReceiver>()
|
var prev = await _dbContext.Set<CommandReceiver>()
|
||||||
.OrderByDescending(x => x.Sequence)
|
.Include (c => c.Command)
|
||||||
|
.Where(x => x.Command.Id == commandID)
|
||||||
.Where(x => x.Sequence < currentSeq)
|
.Where(x => x.Sequence < currentSeq)
|
||||||
|
.OrderByDescending(x => x.Sequence)
|
||||||
.Take(1)
|
.Take(1)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
|
@ -646,8 +650,10 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
{
|
{
|
||||||
// get next record
|
// get next record
|
||||||
var next = await _dbContext.Set<CommandReceiver>()
|
var next = await _dbContext.Set<CommandReceiver>()
|
||||||
.OrderBy(x => x.Sequence)
|
.Include(c => c.Command)
|
||||||
|
.Where(x => x.Command.Id == commandID)
|
||||||
.Where(x => x.Sequence > currentSeq)
|
.Where(x => x.Sequence > currentSeq)
|
||||||
|
.OrderBy(x => x.Sequence)
|
||||||
.Take(1)
|
.Take(1)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue