Ejemplo n.º 1
0
        //进入index后的分页
        public async Task <PagedResultDto <PurchaseOrderListDto> > GetPagedOrdersAsync(GetPurchaseOrderInput input)
        {
            var query = _purchaseOrderRepository.GetAll();
            var count = await query.CountAsync();

            var list = await query
                       .OrderBy(input.Sorting)
                       .PageBy(input.SkipCount, input.MaxResultCount).ToListAsync();

            var dtos = list.MapTo <List <PurchaseOrderListDto> >();

            foreach (var item in dtos)
            {
                var supplier = await _supplierReository.GetAsync(item.SupplierId);

                item.SupplierName = supplier.SupplierName;
            }

            return(new PagedResultDto <PurchaseOrderListDto>(count, dtos));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///Get PurchaseOrders
        /// </summary>
        /// <returns></returns>
        public async Task <List <PurchaseOrderEntyDocumnetwithDetailOutputDto> > GetPurchaseOrderList(GetPurchaseOrderInput input)
        {
            var purchaseOrderReferences = !string.IsNullOrEmpty(input.PurchaseOrderReferences) ? input.PurchaseOrderReferences.Split(',') : null;

            var query = from pounit in _purchaseOrderEntryDocumentUnitRepository.GetAll()
                        join podetails in _purchaseOrderEntryDocumentDetailUnitRepository.GetAll() on pounit.Id equals podetails.AccountingDocumentId.Value
                        select new
            {
                Isclosed          = pounit.IsClose,
                Description       = pounit.Description,
                DocumentReference = pounit.DocumentReference,
                DocumentDate      = pounit.DocumentDate,
                podetails
            };
            var results = await query.Where(p => p.podetails.Amount > 0 && p.Isclosed != true)
                          .WhereIf(!string.IsNullOrEmpty(input.PurchaseOrderReferences), u => purchaseOrderReferences.Contains(u.DocumentReference))
                          .WhereIf(input.VendorId != 0, u => u.podetails.VendorId == input.VendorId).ToListAsync();

            return(results.Select(item =>
            {
                var dto = item.podetails.MapTo <PurchaseOrderEntyDocumnetwithDetailOutputDto>();
                dto.AccountId = item.podetails.Id;
                dto.Description = item.Description;
                dto.DocumentDate = item.DocumentDate;
                dto.DocumentReference = item.DocumentReference;
                return dto;
            }).ToList());
        }