Add recipeid to the methods seperate the Id logic between instructionId and recipeId
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
{
|
{
|
||||||
public interface IInstructionService
|
public interface IInstructionService
|
||||||
{
|
{
|
||||||
Task MoveInstructionUpAsync(Guid instructionId);
|
Task MoveInstructionUpAsync(Guid recipeId, Guid instructionId);
|
||||||
|
|
||||||
Task MoveInstructionDownAsync(Guid instructionId);
|
Task MoveInstructionDownAsync(Guid recipeId, Guid instructionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,15 +11,15 @@ namespace Francesco.Recipes.World.Services.Instruction
|
|||||||
_instructionRepository = instructionRepository;
|
_instructionRepository = instructionRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task MoveInstructionUpAsync(Guid instructionId)
|
public Task MoveInstructionUpAsync(Guid recipeId, Guid instructionId)
|
||||||
=> MoveInstructionAsync(instructionId, moveUp: true);
|
=> MoveInstructionAsync(recipeId, instructionId, moveUp: true);
|
||||||
|
|
||||||
public Task MoveInstructionDownAsync(Guid instructionId)
|
public Task MoveInstructionDownAsync(Guid recipeId, Guid instructionId)
|
||||||
=> MoveInstructionAsync(instructionId, moveUp: false);
|
=> MoveInstructionAsync(recipeId, instructionId, moveUp: false);
|
||||||
|
|
||||||
private async Task MoveInstructionAsync(Guid instructionId, bool moveUp)
|
private async Task MoveInstructionAsync(Guid recipeId, Guid instructionId, bool moveUp)
|
||||||
{
|
{
|
||||||
var instructions = await _instructionRepository.GetInstructionsOfRecipeAsync(instructionId);
|
var instructions = await _instructionRepository.GetInstructionsOfRecipeAsync(recipeId);
|
||||||
|
|
||||||
var instruction = instructions.FirstOrDefault(i => i.Id == instructionId);
|
var instruction = instructions.FirstOrDefault(i => i.Id == instructionId);
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ namespace Francesco.Recipes.World.Services.Instruction
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var targetNumber = moveUp ? instruction.Number + 1 : instruction.Number - 1;
|
var targetNumber = moveUp ? instruction.Number - 1 : instruction.Number + 1;
|
||||||
var neighbor = instructions.FirstOrDefault(i => i.Number == targetNumber);
|
var neighbor = instructions.FirstOrDefault(i => i.Number == targetNumber);
|
||||||
|
|
||||||
if (neighbor != null)
|
if (neighbor != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user