public async Task <ActionResult <ExpenseDto> > GetExpenseAsync(int id) { var expense = await expenseRepository.GetByIdAsync(id, exp => exp.Budget); if (expense == null) { return(NotFound($"No Expense with Id {id} found.")); } if (!IsUserAuthorizedForResource(expense.Budget)) { return(Unauthorized("You can only access your own expenses.")); } var expenseForReturn = mapper.Map <ExpenseDto>(expense); return(Ok(expenseForReturn)); }