public void GivenValidData_InputCreated() { var actual = new GetAccountInput( new AccountId(Guid.NewGuid())); Assert.NotNull(actual); }
/// <summary> /// Get the Records by ProjectCoaId with paging sorting /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <PagedResultOutput <AccountUnitDto> > GetLinesByCoaId(GetAccountInput input) { var query = from au in _accountUnitRepository.GetAll() join typeOfAccount in _typeOfAccountRepository.GetAll() on au.TypeOfAccountId equals typeOfAccount.Id into accounts from accunit in accounts.DefaultIfEmpty() join currencytype in _typeOfCurrencyRepository.GetAll() on au.TypeOfCurrencyId equals currencytype.Id into currencyt from currency in currencyt.DefaultIfEmpty() join rollupacc in _accountUnitRepository.GetAll() on au.RollupAccountId equals rollupacc.Id into rollupaccount from rollupaccounts in rollupaccount.DefaultIfEmpty() join rollupdiv in _jobRepository.GetAll() on au.RollupJobId equals rollupdiv.Id into rollupAccount from rollupAccounts in rollupAccount.DefaultIfEmpty() select new { Account = au, TypeOfAccount = accunit.Description, TypeOfCurrency = currency.Description, RollUpAccountCaption = rollupaccounts.AccountNumber, RollUpDivision = rollupAccounts.JobNumber }; if (!ReferenceEquals(input.Filters, null)) { SearchTypes mapSearchFilters = Helper.MappingFilters(input.Filters); if (!ReferenceEquals(mapSearchFilters, null)) { query = Helper.CreateFilters(query, mapSearchFilters); } } query = query.Where(item => item.Account.ChartOfAccountId == input.CoaId); var resultCount = await query.CountAsync(); var results = await query .AsNoTracking() .OrderBy(Helper.GetSort("Account.AccountNumber ASC", input.Sorting)) .PageBy(input) .ToListAsync(); return(new PagedResultOutput <AccountUnitDto>(resultCount, results.Select(item => { var dto = item.Account.MapTo <AccountUnitDto>(); dto.AccountId = item.Account.Id; dto.TypeofConsolidation = item.Account.TypeofConsolidationId != null ? item.Account.TypeofConsolidationId.ToDisplayName() : ""; dto.TypeOfAccount = item.TypeOfAccount; dto.TypeOfCurrency = item.TypeOfCurrency; dto.RollUpAccountCaption = item.RollUpAccountCaption; dto.RollUpDivision = item.RollUpDivision; return dto; }).ToList())); }
public async Task <IActionResult> Get( [FromServices] IMediator mediator, [FromServices] GetAccountPresenter presenter, [FromRoute][Required] GetAccountRequest request) { var input = new GetAccountInput(request.AccountId); await mediator.PublishAsync(input) .ConfigureAwait(false); return(presenter.ViewModel); }
public async Task <IActionResult> Get( [FromServices] IMediator mediator, [FromServices] GetAccountDetailsPresenterV2 presenter, [FromRoute][Required] GetAccountDetailsRequestV2 request) { var input = new GetAccountInput(new AccountId(request.AccountId)); await mediator.PublishAsync(input, "GetAccountDetailsV2") .ConfigureAwait(false); return(presenter.ViewModel); }
/// <summary> /// Executes the Use Case. /// </summary> /// <param name="input">Input Message.</param> /// <returns>Task.</returns> public async Task Execute(GetAccountInput input) { if (input is null) { this._getAccountOutputPort.WriteError(Messages.InputIsNull); return; } IAccount account = await this._accountRepository .GetAccount(input.AccountId) .ConfigureAwait(false); if (account is null) { this._getAccountOutputPort .NotFound($"The account {input.AccountId.ToGuid()} does not exist or is not processed yet."); return; } this.BuildOutput(account); }
/// <summary> /// Executes the Use Case. /// </summary> /// <param name="input">Input Message.</param> /// <returns>Task.</returns> public async Task Execute(GetAccountInput input) { if (input is null) { this._getAccountOutputPort.WriteError(Messages.InputIsNull); return; } IAccount account = await this._accountRepository .GetAccount(input.AccountId) .ConfigureAwait(false); if (account is null) { this._getAccountOutputPort .NotFound(Messages.AccountDoesNotExist); return; } this.BuildOutput(account); }
public async Task <PagedResultOutput <AccountUnitDto> > GetLinkedAccountUnitsByCoaId(GetAccountInput input) { //get Coa record by coaId var coa = await _coaRepository.FirstOrDefaultAsync(p => p.Id == input.CoaId); int?linkedcoaId = coa.LinkChartOfAccountID; //Get all linkedchartofaccount accounts. var query = from au in _accountUnitRepository.GetAll() join linkaccount in (from account in _accountUnitRepository.GetAll().Where(p => p.ChartOfAccountId == linkedcoaId) join homeAc in _accountLinkRepository.GetAll() on account.Id equals homeAc.MapAccountId.Value select new { account.AccountNumber, homeAc }) on au.Id equals linkaccount.homeAc.HomeAccountId.Value into linkaccountunit from linkaccounts in linkaccountunit.DefaultIfEmpty() join typeOfAccount in _typeOfAccountRepository.GetAll() on au.TypeOfAccountId equals typeOfAccount.Id into accounts from typeofaccounts in accounts.DefaultIfEmpty() join currencytype in _typeOfCurrencyRepository.GetAll() on au.TypeOfCurrencyId equals currencytype.Id into currencyt from currency in currencyt.DefaultIfEmpty() join currencyrate in _typeOfCurrencyRateRepository.GetAll() on au.TypeOfCurrencyRateId equals currencyrate.Id into ratecurrency from accountresults in ratecurrency.DefaultIfEmpty() select new { Account = au, TypeOfAccount = typeofaccounts.Description, TypeOfAccountRate = accountresults.Description, TypeOfCurrency = currency.Description, LinkAccount = linkaccounts.AccountNumber, LinkedAccountUnit = linkaccounts.homeAc }; if (!ReferenceEquals(input.Filters, null)) { SearchTypes mapSearchFilters = Helper.MappingFilters(input.Filters); if (!ReferenceEquals(mapSearchFilters, null)) { query = Helper.CreateFilters(query, mapSearchFilters); } } query = query.Where(item => item.Account.ChartOfAccountId == linkedcoaId); var resultCount = await query.CountAsync(); var results = await query .AsNoTracking() .OrderBy(Helper.GetSort("Account.AccountNumber ASC", input.Sorting)) .PageBy(input) .ToListAsync(); return(new PagedResultOutput <AccountUnitDto>(resultCount, results.Select(item => { var dto = item.Account.MapTo <AccountUnitDto>(); dto.AccountId = item.Account.Id; dto.TypeofConsolidation = item.Account.TypeofConsolidationId != null ? item.Account.TypeofConsolidationId.ToDisplayName() : ""; dto.TypeOfAccount = item.TypeOfAccount; dto.TypeOfCurrency = item.TypeOfCurrency; dto.TypeOfCurrencyRate = item.TypeOfAccountRate; dto.LinkAccount = item.LinkAccount; dto.AccountLinkId = ReferenceEquals(item.LinkedAccountUnit, null) ? (long?)null : item.LinkedAccountUnit.Id; return dto; }).ToList())); }
/// <summary> /// GetAccount /// </summary> /// <param name="input"></param> /// <param name="context"></param> /// <returns></returns> public async Task <Account> GetAccount(GetAccountInput input, ServerCallContext context) { var state = await _daprClient.GetStateEntryAsync <Account>(StoreName, input.Id); return(state.Value); }