Exemplo n.º 1
0
        public async Task <IActionResult> GetReport([FromBody] ReportAuthRequestViewModel reportRequestViewModel)
        {
            try
            {
                var list = await _transactionService.GetTransactionsBetween(reportRequestViewModel);

                return(Ok(list));
            }
            catch (Exception)
            {
                return(Conflict(new ErrorResponseViewModel
                {
                    Id = 400, Message = "ceva o crapat"
                }));
            }
        }
Exemplo n.º 2
0
        public async Task <List <TransactionResponseViewModel> > GetTransactionsBetween(ReportAuthRequestViewModel reportRequestViewModel)
        {
            var url = $"{_configuration["TransactionAPIUrl"]}/api/Transaction/AllInBetween";

            reportRequestViewModel.InternalName = _routerService.GetInternalName(reportRequestViewModel.UserName, reportRequestViewModel.Password);

            try
            {
                var responseString = await HTTPRequestSender.PostAsync(url, reportRequestViewModel);

                var responseUser = JsonConvert.DeserializeObject <List <TransactionResponseViewModel> >(responseString);

                return(responseUser);
            }
            catch (Exception e)
            {
                var errorResponse = JsonConvert.DeserializeObject <ErrorResponseViewModel>(e.Message);

                if (errorResponse.Id == (int)ErrorResponseIds.UserInvalid)
                {
                    throw new UserNotFoundException();
                }

                throw;
            }
        }