public async Task <ActionResult <int> > CountContract([FromBody] Company_ContractFilterDTO Company_ContractFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            ContractFilter ContractFilter = ConvertContractFilterEntity(Company_ContractFilterDTO);

            ContractFilter = await ContractService.ToFilter(ContractFilter);

            int count = await ContractService.Count(ContractFilter);

            return(count);
        }
        private ContractFilter ConvertContractFilterEntity(Company_ContractFilterDTO Company_ContractFilterDTO)
        {
            ContractFilter ContractFilter = new ContractFilter();

            ContractFilter.Selects   = ContractSelect.ALL;
            ContractFilter.Skip      = Company_ContractFilterDTO.Skip;
            ContractFilter.Take      = Company_ContractFilterDTO.Take;
            ContractFilter.OrderBy   = Company_ContractFilterDTO.OrderBy;
            ContractFilter.OrderType = Company_ContractFilterDTO.OrderType;

            ContractFilter.Id                = Company_ContractFilterDTO.Id;
            ContractFilter.Code              = Company_ContractFilterDTO.Code;
            ContractFilter.Name              = Company_ContractFilterDTO.Name;
            ContractFilter.CompanyId         = Company_ContractFilterDTO.CompanyId;
            ContractFilter.OpportunityId     = Company_ContractFilterDTO.OpportunityId;
            ContractFilter.CompanyId         = Company_ContractFilterDTO.CompanyId;
            ContractFilter.ContractTypeId    = Company_ContractFilterDTO.ContractTypeId;
            ContractFilter.TotalValue        = Company_ContractFilterDTO.TotalValue;
            ContractFilter.CurrencyId        = Company_ContractFilterDTO.CurrencyId;
            ContractFilter.ValidityDate      = Company_ContractFilterDTO.ValidityDate;
            ContractFilter.ExpirationDate    = Company_ContractFilterDTO.ExpirationDate;
            ContractFilter.AppUserId         = Company_ContractFilterDTO.AppUserId;
            ContractFilter.DeliveryUnit      = Company_ContractFilterDTO.DeliveryUnit;
            ContractFilter.ContractStatusId  = Company_ContractFilterDTO.ContractStatusId;
            ContractFilter.PaymentStatusId   = Company_ContractFilterDTO.PaymentStatusId;
            ContractFilter.InvoiceAddress    = Company_ContractFilterDTO.InvoiceAddress;
            ContractFilter.InvoiceNationId   = Company_ContractFilterDTO.InvoiceNationId;
            ContractFilter.InvoiceProvinceId = Company_ContractFilterDTO.InvoiceProvinceId;
            ContractFilter.InvoiceDistrictId = Company_ContractFilterDTO.InvoiceDistrictId;
            ContractFilter.InvoiceZipCode    = Company_ContractFilterDTO.InvoiceZipCode;
            ContractFilter.ReceiveAddress    = Company_ContractFilterDTO.ReceiveAddress;
            ContractFilter.ReceiveNationId   = Company_ContractFilterDTO.ReceiveNationId;
            ContractFilter.ReceiveProvinceId = Company_ContractFilterDTO.ReceiveProvinceId;
            ContractFilter.ReceiveDistrictId = Company_ContractFilterDTO.ReceiveDistrictId;
            ContractFilter.ReceiveZipCode    = Company_ContractFilterDTO.ReceiveZipCode;
            ContractFilter.TermAndCondition  = Company_ContractFilterDTO.TermAndCondition;
            ContractFilter.CreatorId         = Company_ContractFilterDTO.CreatorId;
            ContractFilter.OrganizationId    = Company_ContractFilterDTO.OrganizationId;
            return(ContractFilter);
        }
        public async Task <ActionResult <List <Company_ContractDTO> > > ListContract([FromBody] Company_ContractFilterDTO Company_ContractFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            ContractFilter ContractFilter = ConvertContractFilterEntity(Company_ContractFilterDTO);

            ContractFilter = await ContractService.ToFilter(ContractFilter);

            List <Contract> Contracts = await ContractService.List(ContractFilter);

            List <Company_ContractDTO> Company_ContractDTOs = Contracts
                                                              .Select(c => new Company_ContractDTO(c)).ToList();

            return(Company_ContractDTOs);
        }