public async Task <IActionResult> DeleteGoalAsync(Guid id) { if (!Guid.TryParse(HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value, out Guid userId)) { return(Unauthorized()); } var deleteGoalCommand = new DeleteGoalCommand() { Id = id }; var hasBeenDeleted = await _mediator.Send(deleteGoalCommand); return(NoContent()); }
public GoalsController(AllGoalsQuery allGoalsQuery, UserGoalsQuery userGoalsQuery, GoalQuery goalQuery, CreateGoalCommand createGoalCommand, UpdateGoalCommand updateGoalCommand, DeleteGoalCommand deleteGoalCommand, CompleteGoalCommand completeGoalCommand) { this.allGoalsQuery = allGoalsQuery; this.userGoalsQuery = userGoalsQuery; this.goalQuery = goalQuery; this.createGoalCommand = createGoalCommand; this.updateGoalCommand = updateGoalCommand; this.deleteGoalCommand = deleteGoalCommand; this.completeGoalCommand = completeGoalCommand; }