public async Task <IWrappedResponse> Search(PostingAccountsSearchRequest request)
        {
            var query = _olmaPostingAccountRepo.FindAll()
                        .IgnoreQueryFilters()
                        .AsNoTracking().Where(d => !d.IsDeleted);

            if (request.PostingAccountId.HasValue)
            {
                var olmaPostingAccount = await query.Where(d => d.Id == request.PostingAccountId)
                                         .Include(a => a.Address).SingleOrDefaultAsync();

                return(Ok(Mapper.Map <PostingAccountAdministration>(olmaPostingAccount)));
            }

            if (request.CustomerId.HasValue)
            {
                query = query.Where(d => d.CustomerId == request.CustomerId);
                return(Ok(query.ProjectTo <PostingAccountAdministration>(Mapper.ConfigurationProvider)));
            }

            return(new WrappedResponse
            {
                ResultType = ResultType.BadRequest,
                State = ErrorHandler.Create().AddMessage(new GeneralError()).GetServiceState()
            });
        }
        public async Task <ActionResult <PostingAccountAdministration> > GetById(int id)
        {
            var request = new PostingAccountsSearchRequest
            {
                PostingAccountId = id
            };

            return(await _postingAccountsService.Search(request).Convert <PostingAccountAdministration>(this));
        }
        public async Task <ActionResult <IEnumerable <PostingAccountAdministration> > > GetByCustomerId(int id)
        {
            var request = new PostingAccountsSearchRequest
            {
                CustomerId = id
            };

            return(await _postingAccountsService.GetByCustomerId(request).Convert <IEnumerable <PostingAccountAdministration> >(this));
        }
        public async Task <IWrappedResponse> GetByCustomerId(PostingAccountsSearchRequest request)
        {
            var query = _olmaPostingAccountRepo.FindAll()
                        .IgnoreQueryFilters()
                        .AsNoTracking().Where(d => !d.IsDeleted);

            var olmaPostingAccounts = await query.Where(d => d.CustomerId == request.CustomerId)
                                      .Include(a => a.Address).ToListAsync();

            return(Ok(Mapper.Map <IEnumerable <PostingAccountAdministration> >(olmaPostingAccounts
                                                                               .AsEnumerable())));
        }
 public PostingAccountBalanceRule(PostingAccountsSearchRequest request, IRule parentRule)
 {
     // Create Context
     Context    = new ContextModel(request, this);
     ParentRule = parentRule;
 }
Пример #6
0
 public MainRule(PostingAccountsSearchRequest request)
 {
     // Create Context
     Context = new ContextModel(request, this);
 }
        public async Task <LoadResult> Get(DataSourceLoadOptions loadOptions, [FromQuery] PostingAccountsSearchRequest request)
        {
            var response = (WrappedResponse <IQueryable <PostingAccountAdministration> >) await _postingAccountsService.Search(request);

            return(await DataSourceLoader.LoadAsync(response.Data, loadOptions));
        }