public Task <FilterResultModel <PartnersRentPaymentHistoryModel> > Handle(GetPartnersRentPaymentHistoryQuery request, CancellationToken cancellationToken)
        {
            var sortBy        = request.SortBy.Trim() != "" ? request.SortBy : "PartnerName";
            var sortDirection = (request.SortDirection.ToUpper() == "DESCENDING") ? true : false;

            FilterResultModel <PartnersRentPaymentHistoryModel> result = new FilterResultModel <PartnersRentPaymentHistoryModel> ();

            var history = _database.Rent
                          .Select(PartnersRentPaymentHistoryModel.Projection)
                          .Select(DynamicQueryHelper.GenerateSelectedColumns <PartnersRentPaymentHistoryModel> (request.SelectedColumns))
                          .AsQueryable();

            if (request.Filter.Count() > 0)
            {
                history = history
                          .Where(DynamicQueryHelper
                                 .BuildWhere <PartnersRentPaymentHistoryModel> (request.Filter));
            }

            result.Count = history.Count();
            var PageSize   = (request.PageSize == 0) ? result.Count : request.PageSize;
            var PageNumber = (request.PageSize == 0) ? 1 : request.PageNumber;

            result.Items = history.OrderBy(sortBy, sortDirection)
                           .Skip(PageNumber - 1)
                           .Take(PageSize)
                           .ToList();
            return(Task.FromResult <FilterResultModel <PartnersRentPaymentHistoryModel> > (result));
        }
예제 #2
0
        public async Task <ActionResult <FilterResultModel <PartnersRentHistoryModel> > > GetPartnersRentPaymentHistory([FromBody] GetPartnersRentPaymentHistoryQuery query)
        {
            var history = await _Mediator.Send(query);

            return(Ok(history));
        }