コード例 #1
0
        public async Task <IActionResult> UpdateSavingsGoal(Guid goalId, [FromBody] SavingsGoalViewModel goal)
        {
            var userId  = Guid.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
            var updated = await _savingsGoalService.UpdateSavingsGoal(goalId, userId, goal.Name, goal.CurrentAmount, goal.TargetAmount);

            if (updated != null)
            {
                return(Ok(updated));
            }

            return(StatusCode(500, "Nothing was updated."));
        }
コード例 #2
0
        public async Task <IActionResult> AddSavingsGoal(SavingsGoalViewModel goal)
        {
            var userId = Guid.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
            var added  = await _savingsGoalService.AddSavingsGoal(userId, goal.Name, goal.CurrentAmount, goal.TargetAmount);

            if (added != null)
            {
                return(Ok(added));
            }

            return(StatusCode(500, "Nothing was added."));
        }