public async Task <SearchTransactionResponse> GetAccountTransactionsAsync(ClaimsPrincipal claimsPrincipal) { SearchTransactionResponse response = new SearchTransactionResponse(); try { var user = await this.userRepository.GetByIdAsync(claimsPrincipal.GetUserId()); if (user.Account.IsNotNull()) { response.Transactions = await this.transactionRepository.GetAccountTransactionsAsync(user.Account); } else { response.Errors.Add(new Error() { Code = ((int)ErrorCodes.NotFound).ToString(), Message = $"Account was not found" }); } } catch (Exception exc) { response.IsSuccessful = false; response.Errors.Add(new Error() { Code = ((int)ErrorCodes.Unknown).ToString(), Message = "There was a problem. Please try again later" }); } return(response); }
public SearchTransactionResponse SearchTransactionByUser(Request req) { SearchTransactionResponse res = new SearchTransactionResponse(); using (DATransaction da = new DATransaction()) { res.Transactions = da.SearchTransactionByUser(User.Id); } res.IsSuccessful = true; return(res); }
public async Task <SearchTransactionResponse> GetBusinessTransactionsAsync(ClaimsPrincipal claimsPrincipal) { SearchTransactionResponse response = new SearchTransactionResponse(); try { response.Transactions = await this.transactionRepository.GetBusinessesTransactionsAsync(claimsPrincipal.GetUserId()); } catch (Exception) { response.IsSuccessful = false; response.Errors.Add(new Error() { Code = ((int)ErrorCodes.Unknown).ToString(), Message = "There was a problem. Please try again later" }); } return(response); }