public async Task <IActionResult> Create([FromBody] CreateUpcomingExpense dto) { if (dto == null) { return(BadRequest()); } try { dto.UserId = IdentityHelper.GetUserId(User); } catch (UnauthorizedAccessException) { return(Unauthorized()); } int id = await _upcomingExpenseService.CreateAsync(dto); return(StatusCode(201, id)); }
public Task <int> CreateAsync(CreateUpcomingExpense model) { var upcomingExpense = _mapper.Map <UpcomingExpense>(model); return(_upcomingExpensesRepository.CreateAsync(upcomingExpense)); }