public async Task <long> CountItem([FromBody] OpportunityReport_ItemFilterDTO OpportunityReport_ItemFilterDTO)
 {
     if (OpportunityReport_ItemFilterDTO.OpportunityReportId != null)
     {
         var query = (from t1 in DataContext.Item
                      join t2 in DataContext.OpportunityItemMapping on t1.Id equals t2.ItemId
                      where t2.OpportunityId == OpportunityReport_ItemFilterDTO.OpportunityReportId.Equal
                      select new
         {
             Name = t1.Name,
             UnitOfMeasureName = t2.UnitOfMeasure == null ? "" : t2.UnitOfMeasure.Name,
             RequestQuantity = t2.RequestQuantity,
             SalePrice = t2.SalePrice,
             RevenueOfItem = t2.RequestQuantity * t2.SalePrice,
         }).ToList();
         return(query.Count());
     }
     return(0);
 }
        public async Task <ActionResult <List <OpportunityReport_ItemDTO> > > FilterListItem([FromBody] OpportunityReport_ItemFilterDTO OpportunityReport_ItemFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            ItemFilter ItemFilter = new ItemFilter();

            ItemFilter.Skip        = 0;
            ItemFilter.Take        = 20;
            ItemFilter.OrderBy     = ItemOrder.Id;
            ItemFilter.OrderType   = OrderType.ASC;
            ItemFilter.Selects     = ItemSelect.ALL;
            ItemFilter.Id          = OpportunityReport_ItemFilterDTO.Id;
            ItemFilter.ProductId   = OpportunityReport_ItemFilterDTO.ProductId;
            ItemFilter.Code        = OpportunityReport_ItemFilterDTO.Code;
            ItemFilter.Name        = OpportunityReport_ItemFilterDTO.Name;
            ItemFilter.ScanCode    = OpportunityReport_ItemFilterDTO.ScanCode;
            ItemFilter.SalePrice   = OpportunityReport_ItemFilterDTO.SalePrice;
            ItemFilter.RetailPrice = OpportunityReport_ItemFilterDTO.RetailPrice;

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

            List <OpportunityReport_ItemDTO> OpportunityReport_ItemDTOs = Items
                                                                          .Select(x => new OpportunityReport_ItemDTO(x)).ToList();

            return(OpportunityReport_ItemDTOs);
        }