public Task <IActionResult> AddConjugateExerciseStepAsync( [FromRoute] string userId, [FromRoute] string targetId, [FromRoute] string serieId, [FromBody] ConjugateExerciseStepDto exercise, [FromServices] IExerciseStepApplicationService service) => AddExerciseStepAsync(userId, targetId, serieId, exercise, service);
public async Task <IActionResult> DeleteAsync([FromRoute] string userId, [FromRoute] string targetId, [FromRoute] string serieId, [FromRoute] string id, [FromServices] IExerciseStepApplicationService service) { if (!string.Equals(User.Identity.Name, userId)) { return(Forbid()); } try { if (!await service.DeleteByAsync(userId, targetId, serieId, id)) { return(NotFound()); } return(StatusCode(204)); } catch (ArgumentException ex) { return(BadRequest(new { reason = ex.Message })); } catch (Exception ex) { Console.WriteLine(ex); return(Problem("Something is not right, calm down calm down! We're working to fix...(I hope so!")); } }
public async Task <IActionResult> GetExerciseStepByIdAsync([FromRoute] string userId, [FromRoute] string targetId, [FromRoute] string serieId, [FromRoute] string id, [FromServices] IExerciseStepApplicationService service) { if (!string.Equals(User.Identity.Name, userId)) { return(Forbid()); } var registeredExecise = await service.GetByIdAsync(userId, targetId, serieId, id); if (registeredExecise == null) { return(NotFound()); } return(Ok(registeredExecise)); }
private async Task <IActionResult> AddExerciseStepAsync(string userId, string targetId, string serieId, IExerciseStepDto exercise, IExerciseStepApplicationService service) { if (!string.Equals(User.Identity.Name, userId)) { return(Forbid()); } try { var registeredExercise = await service.AddAsync(userId, targetId, serieId, exercise); return(CreatedAtRoute(nameof(GetExerciseStepByIdAsync), new { userId, targetId, serieId, id = registeredExercise.Id }, registeredExercise)); } catch (Application.Exceptions.ApplicationException ex) { return(BadRequest(ex.ToResult())); } catch (ArgumentException ex) { return(BadRequest(new { reason = ex.Message })); } catch (Exception ex) { Console.WriteLine(ex); return(Problem("Something is not right, calm down calm down! We're working to fix...(I hope so!")); } }