Rename Refactoring
This commit is contained in:
@@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
Task RemoveInstructionFromRecipeAsync(Guid recipeId, Guid instructionId);
|
Task RemoveInstructionFromRecipeAsync(Guid recipeId, Guid instructionId);
|
||||||
|
|
||||||
Task SwapInstructionOrderAsync(Instruction a, Instruction b);
|
Task SwapInstructionNumbersAsync(Instruction a, Instruction b);
|
||||||
|
|
||||||
Task<List<Instruction>> GetInstructionsByInstructionIdAsync(Guid instructionId);
|
Task<List<Instruction>> GetInstructionsOfRecipeAsync(Guid instructionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<Instruction>> GetInstructionsByInstructionIdAsync(Guid instructionId)
|
public async Task<List<Instruction>> GetInstructionsOfRecipeAsync(Guid instructionId)
|
||||||
{
|
{
|
||||||
var instruction = await _context.Instructions
|
var instruction = await _context.Instructions
|
||||||
.Include(i => i.Recipe)
|
.Include(i => i.Recipe)
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
return instruction.Recipe.Instructions.ToList();
|
return instruction.Recipe.Instructions.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SwapInstructionOrderAsync(Instruction a, Instruction b)
|
public async Task SwapInstructionNumbersAsync(Instruction a, Instruction b)
|
||||||
{
|
{
|
||||||
if (a == null)
|
if (a == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Francesco.Recipes.World.Services.Instruction
|
|||||||
|
|
||||||
private async Task MoveInstructionAsync(Guid instructionId, bool moveUp)
|
private async Task MoveInstructionAsync(Guid instructionId, bool moveUp)
|
||||||
{
|
{
|
||||||
var instructions = await _instructionRepository.GetInstructionsByInstructionIdAsync(instructionId);
|
var instructions = await _instructionRepository.GetInstructionsOfRecipeAsync(instructionId);
|
||||||
|
|
||||||
var instruction = instructions.FirstOrDefault(i => i.Id == instructionId);
|
var instruction = instructions.FirstOrDefault(i => i.Id == instructionId);
|
||||||
|
|
||||||
@@ -36,12 +36,12 @@ 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)
|
||||||
{
|
{
|
||||||
await _instructionRepository.SwapInstructionOrderAsync(instruction, neighbor);
|
await _instructionRepository.SwapInstructionNumbersAsync(instruction, neighbor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user