public ActionResult <TransactionDto> CreateTransaction(TransactionForCreationDto transaction)
        {
            var transactionEntity = _mapper.Map <Entities.Transaction>(transaction);

            _financialGoalsRepository.AddTransaction(transactionEntity);
            _financialGoalsRepository.Save();

            var transactionToReturn = _mapper.Map <TransactionDto>(transactionEntity);

            return(CreatedAtRoute("GetTransaction", new { transactionId = transactionToReturn.Id }, transactionToReturn));
        }
Esempio n. 2
0
        public ActionResult <GoalDto> CreateGoal(GoalForCreationDto goal)
        {
            var goalEntity = _mapper.Map <Entities.Goal>(goal);

            goalEntity.UserId = AuthUser.Id;
            _financialGoalsRepository.AddGoal(goalEntity);
            _financialGoalsRepository.Save();

            var goalToReturn = _mapper.Map <GoalDto>(goalEntity);

            return(CreatedAtRoute("GetGoal", new { goalId = goalToReturn.Id }, goalToReturn));
        }
        public IActionResult Register(UserForCreationDto user)
        {
            user.Password = BCrypt.Net.BCrypt.HashPassword(user.Password);
            var userEntity = _mapper.Map <Entities.User>(user);

            _financialGoalsRepository.AddUser(userEntity);
            _financialGoalsRepository.Save();

            var userToReturn = _mapper.Map <UserDto>(userEntity);

            return(Created("AddUser", userToReturn));
        }