예제 #1
0
        public async Task <IActionResult> CompleteGoalAsync(Guid id)
        {
            if (!Guid.TryParse(HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value, out Guid userId))
            {
                return(Unauthorized());
            }

            var completeGoalCommand = new CompleteGoalCommand()
            {
                Id = id
            };
            var hasBeenCompleted = await _mediator.Send(completeGoalCommand);

            return(NoContent());
        }
예제 #2
0
 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;
 }