コード例 #1
0
        public async Task <ActionResult <long> > CountItem([FromBody] Contract_ItemFilterDTO Contract_ItemFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            ItemFilter ItemFilter = new ItemFilter();

            ItemFilter.Id          = Contract_ItemFilterDTO.Id;
            ItemFilter.Code        = Contract_ItemFilterDTO.Code;
            ItemFilter.Name        = Contract_ItemFilterDTO.Name;
            ItemFilter.ProductId   = Contract_ItemFilterDTO.ProductId;
            ItemFilter.RetailPrice = Contract_ItemFilterDTO.RetailPrice;
            ItemFilter.SalePrice   = Contract_ItemFilterDTO.SalePrice;
            ItemFilter.ScanCode    = Contract_ItemFilterDTO.ScanCode;
            ItemFilter.StatusId    = new IdFilter {
                Equal = StatusEnum.ACTIVE.Id
            };

            ItemFilter = ItemService.ToFilter(ItemFilter);

            return(await ItemService.Count(ItemFilter));
        }
コード例 #2
0
        public async Task <ActionResult <List <Contract_ItemDTO> > > ListItem([FromBody] Contract_ItemFilterDTO Contract_ItemFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            ItemFilter ItemFilter = new ItemFilter();

            ItemFilter.Skip        = Contract_ItemFilterDTO.Skip;
            ItemFilter.Take        = Contract_ItemFilterDTO.Take;
            ItemFilter.OrderBy     = ItemOrder.Id;
            ItemFilter.OrderType   = OrderType.ASC;
            ItemFilter.Selects     = ItemSelect.ALL;
            ItemFilter.Id          = Contract_ItemFilterDTO.Id;
            ItemFilter.Code        = Contract_ItemFilterDTO.Code;
            ItemFilter.Name        = Contract_ItemFilterDTO.Name;
            ItemFilter.ProductId   = Contract_ItemFilterDTO.ProductId;
            ItemFilter.RetailPrice = Contract_ItemFilterDTO.RetailPrice;
            ItemFilter.SalePrice   = Contract_ItemFilterDTO.SalePrice;
            ItemFilter.ScanCode    = Contract_ItemFilterDTO.ScanCode;
            ItemFilter.StatusId    = new IdFilter {
                Equal = StatusEnum.ACTIVE.Id
            };
            ItemFilter = ItemService.ToFilter(ItemFilter);

            List <Item> Items = await ContractService.ListItem(ItemFilter);

            List <Contract_ItemDTO> Contract_ItemDTOs = Items
                                                        .Select(x => new Contract_ItemDTO(x)).ToList();

            return(Contract_ItemDTOs);
        }