Beispiel #1
0
        public IActionResult GetUserCategories(int id)
        {
            var user = _userService.GetById(id);

            if (user == null)
            {
                return(NotFound(_errorService.NotFound("user", id, HttpContext.Request)));
            }

            if (user is User)
            {
                var userCategories   = _categoryService.GetUserCategories(id);
                var userCategoryDtos = _mapper.Map <IEnumerable <CategoryDto> >(userCategories);
                return(Ok(userCategoryDtos));
            }
            return(BadRequest(_errorService.BadRequest("user", id, HttpContext.Request)));
        }
        public IActionResult GetUserTransactionAccounts(int id)
        {
            var user = _userService.GetById(id);

            if (user == null)
            {
                return(NotFound(_errorService.NotFound("user", id, HttpContext.Request)));
            }

            if (user is User)
            {
                var userTransactionAccounts    = _transactionAccountService.GetUserTransactionAccounts(id);
                var userTransactionAccountDtos = _mapper.Map <IEnumerable <TransactionAccountDto> >(userTransactionAccounts);
                return(Ok(userTransactionAccountDtos));
            }
            return(BadRequest(_errorService.BadRequest("user", id, HttpContext.Request)));
        }
Beispiel #3
0
        public async Task <IActionResult> Authenticate([FromBody] GreenlitAuthDto authDto)
        {
            try
            {
                JwtResponse jwt = await _userService.AuthenticateApiUser(authDto.ApiId, authDto.AuthToken);

                return(Ok(jwt));
            }
            catch (AppException ex) {
                return(BadRequest(_errorService.BadRequest(ex, HttpContext.Request)));
            }
        }
        public IActionResult GetTransactionAccountTransactions(int id)
        {
            var transactionAccount = _transactionAccountService.GetById(id);

            if (transactionAccount == null)
            {
                return(NotFound(_errorService.NotFound("transaction account", id, HttpContext.Request)));
            }

            if (transactionAccount is TransactionAccount)
            {
                var transactionAccountTransactions    = _transactionService.GetTransactionAccountTransactions(id);
                var transactionAccountTransactionDtos = _mapper.Map <IEnumerable <TransactionDto> >(transactionAccountTransactions);
                return(Ok(transactionAccountTransactionDtos));
            }
            return(BadRequest(_errorService.BadRequest("transaction account", id, HttpContext.Request)));
        }