Skip to content

Commit

Permalink
Update WorkoutExerciseSetController routes
Browse files Browse the repository at this point in the history
  • Loading branch information
astijusar committed Nov 5, 2023
1 parent 91c8941 commit b18b6a9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/API/Controllers/WorkoutExerciseSetController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace API.Controllers
{
[Route("api/exercise/{exerciseId}/set")]
[Route("api/workout/{workoutId}/exercise/{exerciseId}/set")]
[ApiController]
public class WorkoutExerciseSetController : ControllerBase
{
Expand All @@ -24,7 +24,7 @@ public WorkoutExerciseSetController(ILogger<WorkoutExerciseSetController> logger
}

[HttpGet]
public async Task<IActionResult> GetExerciseSets(Guid exerciseId)
public async Task<IActionResult> GetExerciseSets(Guid workoutId, Guid exerciseId)
{
var exerciseSets = await _repository.WorkoutExerciseSet.GetExerciseSetsAsync(exerciseId, false);

Expand All @@ -34,7 +34,7 @@ public async Task<IActionResult> GetExerciseSets(Guid exerciseId)
}

[HttpGet("{setId:guid}", Name = "GetExerciseSet")]
public async Task<IActionResult> GetExerciseSet(Guid exerciseId, Guid setId)
public async Task<IActionResult> GetExerciseSet(Guid workoutId, Guid exerciseId, Guid setId)
{
var exerciseSet = await _repository.WorkoutExerciseSet.GetExerciseSetAsync(exerciseId, setId, false);

Expand All @@ -50,7 +50,7 @@ public async Task<IActionResult> GetExerciseSet(Guid exerciseId, Guid setId)

[HttpPost]
[ServiceFilter(typeof(ValidationFilterAttribute))]
public async Task<IActionResult> CreateExerciseSet(Guid exerciseId, [FromBody] WorkoutExerciseSetCreationDto input)
public async Task<IActionResult> CreateExerciseSet(Guid workoutId, Guid exerciseId, [FromBody] WorkoutExerciseSetCreationDto input)
{
var exerciseSet = _mapper.Map<WorkoutExerciseSet>(input);

Expand All @@ -59,12 +59,12 @@ public async Task<IActionResult> CreateExerciseSet(Guid exerciseId, [FromBody] W

var exerciseSetDto = _mapper.Map<WorkoutExerciseSetDto>(exerciseSet);

return CreatedAtRoute("GetExerciseSet", new { exerciseId, setId = exerciseSetDto.Id }, exerciseSetDto);
return CreatedAtRoute("GetExerciseSet", new { workoutId, exerciseId, setId = exerciseSetDto.Id }, exerciseSetDto);
}

[HttpPut("{setId:guid}")]
[ServiceFilter(typeof(ValidationFilterAttribute))]
public async Task<IActionResult> UpdateSet(Guid exerciseId, Guid setId,
public async Task<IActionResult> UpdateSet(Guid workoutId, Guid exerciseId, Guid setId,
[FromBody] WorkoutExerciseSetUpdateDto input)
{
var exercise = await _repository.WorkoutExerciseSet.GetExerciseSetAsync(exerciseId, setId, true);
Expand All @@ -82,7 +82,7 @@ public async Task<IActionResult> UpdateSet(Guid exerciseId, Guid setId,


[HttpDelete("{setId:guid}")]
public async Task<IActionResult> DeleteExerciseSet(Guid exerciseId, Guid setId)
public async Task<IActionResult> DeleteExerciseSet(Guid workoutId, Guid exerciseId, Guid setId)
{
var exerciseSet = await _repository.WorkoutExerciseSet.GetExerciseSetAsync(exerciseId, setId, true);

Expand Down

0 comments on commit b18b6a9

Please sign in to comment.