public async Task GetAccountsTest() { var request = new AccountListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret); var accountList = await AccountService.GetAccountsAsync(request); Assert.IsTrue(accountList.Data.ToList().Count > 0); }
/// <summary> /// 用户信息 /// </summary> /// <param name="request">请求实体</param> /// <returns></returns> public AccountListResponse List(AccountListRequest request) { string postData = JsonHelper.GetJson(request); AccountListResponse response = client.Execute(request, list, postData); return(response); }
public async Task <HttpResponseMessage> List(Guid owner, AccountListRequest input) { var request = new AccountList { Owner = owner, Request = input }; return(await this.ProcessActionAsync(request, this.accountService.List)); }
public async Task GetAccountsFromDateToDateTest() { var request = new AccountListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret) { SearchParameters = new Dictionary <AccountSearchParameters, object>() { { AccountSearchParameters.SRU, 1 } } }; request.SearchParameters.Add(AccountSearchParameters.FinancialYearDate, DateTime.Parse("2016-01-01").ToString("yyyy-MM-dd")); var accountList = await AccountService.GetAccountsAsync(request); Assert.IsNotNull(accountList); }
public async Task <IActionResult> GetJtable(AccountListRequest jtableModel) { try { //var appserviceRequest = jtableModel.ToModel(); var response = await accountAppService.GetAccount(jtableModel); return(Ok(response)); } catch (Exception ex) { logger.LogError(ex, ex.Message); return(BadRequest()); } }
public Task <AccountListResponse> GetAccount(AccountListRequest request) { var response = new AccountListResponse(); TryCatch(() => { var data = accountService.GetAccounts(request.Keyword, request.Name, request.Type, request.Actives); var responseData = data .Select(m => { var model = AutoMapper.Mapper.Map <Account, AccountView>(m); if (model.Type == (int)AccountTypeConfig.Credit) { model.TypeDisplay = "Ghi nợ"; } else if (model.Type == (int)AccountTypeConfig.Debit) { model.TypeDisplay = "Ghi có"; } else if (model.Type == (int)AccountTypeConfig.Duality) { model.TypeDisplay = "Lưỡng tính"; } else if (model.Type == (int)AccountTypeConfig.Nobalance) { model.TypeDisplay = "Không có số dư"; } else { model.TypeDisplay = ""; } var lstChildrenAccount = GetListParentAccountView(model.Id); model.subChildren = lstChildrenAccount; return(model); }) .ToList(); response.SetData(responseData).Successful(); }, response); return(Task.FromResult(response)); }
public void GetCustomerInvoicesPaginationTest() { var request = new AccountListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret); request.SearchParameters.Add(AccountSearchParameters.FinancialYearDate, DateTime.UtcNow.ToString("yyyy-MM-dd")); request.Limit = 50; request.Page = 1; var accounts = new List <AccountSubset>(); ListedResourceResponse <AccountSubset> response; do { response = AccountService.GetAccountsAsync(request).GetAwaiter().GetResult(); accounts.AddRange(response.Data); request.Page = response.MetaInformation.CurrentPage + 1; } while (response.MetaInformation.CurrentPage != response.MetaInformation.TotalPages); Assert.IsTrue(accounts.Count > 10); }
public async Task <HttpResponseMessage> List(Guid owner) { var type = new List <AccountType>(); type.Add(AccountType.CurrentAccount); type.Add(AccountType.LoanAccount); type.Add(AccountType.SavingAccount); var newInput = new AccountListRequest { Filter = new AccountListFilter { Bank = Guid.Empty, BringArchived = true, BringOnlyMine = false, Currency = string.Empty, Description = string.Empty, DescriptionExact = false, FilterByBank = false, FilterByCurrency = false, FilterByHolder = false, Holder = Guid.Empty, Number = string.Empty, Types = type }, Order = new AccountListOrder { Field = AccountField.Description, IsDesc = false }, ItemsPerPage = 500, Page = 1 }; var request = new AccountList { Owner = owner, Request = newInput }; return(await this.ProcessActionAsync(request, this.accountService.List)); }
private async Task <List <AccountSubset> > GetAccounts() { var request = new AccountListRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); return((await AccountService.GetAccountsAsync(request)).Data.ToList()); }
public static async Task <ListedResourceResponse <AccountSubset> > GetAccountsAsync(AccountListRequest listRequest) { var apiRequest = new FortnoxApiClientRequest <ListedResourceResponse <AccountSubset> >(HttpMethod.Get, listRequest.AccessToken, listRequest.ClientSecret, ApiEndpoints.Accounts); apiRequest.SetSortOrder(listRequest.SortBy?.ToString(), listRequest.SortOrder.ToString()); apiRequest.SetPageAndLimit(listRequest.Page, listRequest.Limit); foreach (var param in listRequest.SearchParameters) { apiRequest.AddSearchParam(param.Key.ToString().ToLower(), param.Value); } return(await FortnoxAPIClient.CallAsync(apiRequest)); }
/// <summary> /// The list. /// </summary> /// <param name="owner"> /// The owner. /// </param> /// <param name="input"> /// The input. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> public Task <HttpResponseMessage> List(Guid owner, AccountListRequest input) { throw new NotImplementedException(); }
/// <summary> /// The list. /// </summary> /// <param name="owner">The owner.</param> /// <param name="input">The input.</param> /// <returns>The <see cref="Task"/>.</returns> public async Task <AccountListResponse> List(Guid owner, AccountListRequest input) { IQueryable <AccountEntity> listQuery = this.context.Accounts.Where(o => o.Owner == owner && ((!input.Filter.BringArchived && !o.IsArchived) || input.Filter.BringArchived)); if (!string.IsNullOrEmpty(input.Filter.Description)) { listQuery = input.Filter.DescriptionExact ? listQuery.Where(x => x.Description == input.Filter.Description) : listQuery.Where(x => x.Description.Contains(input.Filter.Description)); } if (input.Filter.FilterByBank) { listQuery = listQuery.Where(x => x.Bank == input.Filter.Bank); } if (input.Filter.FilterByCurrency && !string.IsNullOrEmpty(input.Filter.Currency)) { listQuery = listQuery.Where(x => x.Currency == input.Filter.Currency); } if (input.Filter.FilterByHolder && !input.Filter.BringOnlyMine) { listQuery = listQuery.Where(x => x.Holder == input.Filter.Holder); } if (input.Filter.BringOnlyMine) { listQuery = listQuery.Where(x => x.Holder == owner); } if (!string.IsNullOrEmpty(input.Filter.Number)) { listQuery = listQuery.Where(x => x.Number.Contains(input.Filter.Number)); } listQuery = listQuery.Where(x => (input.Filter.Types.Contains(AccountType.CurrentAccount) && x is CurrentAccountEntity) || (input.Filter.Types.Contains(AccountType.LoanAccount) && x is LoanAccountEntity) || (input.Filter.Types.Contains(AccountType.SavingAccount) && x is SavingAccountEntity)); var queryResult = await listQuery.CountAsync(); var orderType = input.Order.IsDesc ? SortOrder.Descending : SortOrder.Ascending; var list = await listQuery .OrderByFieldAccount(orderType, input.Order.Field) .Skip((input.Page - 1) * input.ItemsPerPage) .Take(input.ItemsPerPage) .Select(order => new { order.Code, order.StartDate, order.Number, order.Description, order.Currency, order.Amount, order.Holder, order.Bank, order.ChangeAt, order.CreatedAt, order.IsArchived, Type = order is CurrentAccountEntity ? AccountType.CurrentAccount : order is LoanAccountEntity ? AccountType.LoanAccount : AccountType.SavingAccount }).ToListAsync(); var lisOfGuids = list.GroupBy(o => o.Holder).Select(g => g.Key).ToList(); var listOfHolders = await this.humanRepository.GetList(owner, lisOfGuids); var result = new AccountListResponse { NumberOfItems = queryResult, Data = list.Select(order => new Account { Code = order.Code, StartDate = order.StartDate, Number = order.Number, Description = order.Description, Currency = this.cacheProvider.Currencies.FirstOrDefault(o => o.Code == order.Currency), Amount = order.Amount, Holder = listOfHolders.FirstOrDefault(i => i.Code == order.Holder), Bank = this.cacheProvider.Banks.FirstOrDefault(o => o.Code == order.Bank), ChangeAt = order.ChangeAt, CreatedAt = order.CreatedAt, IsArchived = order.IsArchived, Type = order.Type }).ToList() }; return(result); }