public async Task <ActionResult <BudgetDto> > CreateBudgetAsync([FromBody] CreateBudgetDto budgetForCreateDto) { var newBudget = mapper.Map <Budget>(budgetForCreateDto); newBudget.TaxLiability = new TaxLiability(); if (!IsUserAuthorizedForResource(newBudget)) { return(Unauthorized("You can only create budgets for yourself.")); } budgetRepository.Add(newBudget); var saveResult = await budgetRepository.SaveAllAsync(); if (!saveResult) { return(BadRequest("Unable to create budget.")); } var budgetForReturn = mapper.Map <BudgetDto>(newBudget); return(CreatedAtRoute("GetBudgetAsync", new { id = budgetForReturn.Id }, budgetForReturn)); }