public List <OtherDispatchAllocationDto> GetCommitedTransferAllocationsDetached(UserProfile user, int hubId, bool?closedToo, int?CommodityType)
        {
            List <OtherDispatchAllocationDto> TransferList = new List <OtherDispatchAllocationDto>();

            var Transafers = (from v in _unitOfWork.OtherDispatchAllocationRepository.Get()
                              //  where v.HubID == user.DefaultHub.HubID && v.Hub1.HubOwnerID == user.DefaultHub.HubOwnerID
                              where v.HubID == hubId
                              select v
                              );


            if (closedToo == null || closedToo == false)
            {
                Transafers = Transafers.Where(p => p.IsClosed == false);
            }
            else
            {
                Transafers = Transafers.Where(p => p.IsClosed == true);
            }

            if (CommodityType.HasValue)
            {
                Transafers = Transafers.Where(p => p.Commodity.CommodityTypeID == CommodityType.Value);
            }
            else
            {
                Transafers = Transafers.Where(p => p.Commodity.CommodityTypeID == 1);//by default
            }

            foreach (var otherDispatchAllocation in Transafers)
            {
                var transfer = new OtherDispatchAllocationDto();

                transfer.OtherDispatchAllocationID = otherDispatchAllocation.OtherDispatchAllocationID;
                transfer.ReferenceNumber           = otherDispatchAllocation.ReferenceNumber;
                transfer.CommodityName             = otherDispatchAllocation.Commodity.Name;
                transfer.EstimatedDispatchDate     = otherDispatchAllocation.EstimatedDispatchDate;
                transfer.AgreementDate             = otherDispatchAllocation.AgreementDate;
                transfer.SINumber    = otherDispatchAllocation.ShippingInstruction.Value;
                transfer.ProjectCode = otherDispatchAllocation.ProjectCode.Value;
                transfer.IsClosed    = otherDispatchAllocation.IsClosed;

                transfer.QuantityInUnit          = otherDispatchAllocation.QuantityInUnit;
                transfer.RemainingQuantityInUnit = otherDispatchAllocation.RemainingQuantityInUnit;

                if (user.PreferedWeightMeasurment.ToUpperInvariant() == "QN")
                {
                    transfer.QuantityInMT          = Math.Abs(otherDispatchAllocation.QuantityInMT) * 10;
                    transfer.RemainingQuantityInMt = (otherDispatchAllocation.RemainingQuantityInMt) * 10;
                }
                else
                {
                    transfer.QuantityInMT          = Math.Abs(otherDispatchAllocation.QuantityInMT);
                    transfer.RemainingQuantityInMt = (otherDispatchAllocation.RemainingQuantityInMt);
                }
                TransferList.Add(transfer);
            }
            return(TransferList);
        }
        public List <OtherDispatchAllocationDto> GetCommitedLoanAllocationsDetached(UserProfile user, bool?closedToo, int?CommodityType)
        {
            List <OtherDispatchAllocationDto> LoanList = new List <OtherDispatchAllocationDto>();

            var Loans = (from v in db.OtherDispatchAllocations
                         where v.HubID == user.DefaultHub.HubID && v.Hub1.HubOwnerID != user.DefaultHub.HubOwnerID
                         select v
                         );


            if (closedToo == null || closedToo == false)
            {
                Loans = Loans.Where(p => p.IsClosed == false);
            }
            else
            {
                Loans = Loans.Where(p => p.IsClosed == true);
            }

            if (CommodityType.HasValue)
            {
                Loans = Loans.Where(p => p.Commodity.CommodityTypeID == CommodityType.Value);
            }
            else
            {
                Loans = Loans.Where(p => p.Commodity.CommodityTypeID == 1);//by default
            }

            foreach (var otherDispatchAllocation in Loans)
            {
                var loan = new OtherDispatchAllocationDto();

                loan.OtherDispatchAllocationID = otherDispatchAllocation.OtherDispatchAllocationID;
                loan.ReferenceNumber           = otherDispatchAllocation.ReferenceNumber;
                loan.CommodityName             = otherDispatchAllocation.Commodity.Name;
                loan.EstimatedDispatchDate     = otherDispatchAllocation.EstimatedDispatchDate;
                loan.AgreementDate             = otherDispatchAllocation.AgreementDate;
                loan.SINumber    = otherDispatchAllocation.ShippingInstruction.Value;
                loan.ProjectCode = otherDispatchAllocation.ProjectCode.Value;
                loan.IsClosed    = otherDispatchAllocation.IsClosed;

                loan.QuantityInUnit          = otherDispatchAllocation.QuantityInUnit;
                loan.RemainingQuantityInUnit = otherDispatchAllocation.QuantityInUnit;

                if (user.PreferedWeightMeasurment.ToUpperInvariant() == "QN")
                {
                    loan.QuantityInMT          = Math.Abs(otherDispatchAllocation.QuantityInMT) * 10;
                    loan.RemainingQuantityInMt = (otherDispatchAllocation.RemainingQuantityInMt) * 10;
                }
                else
                {
                    loan.QuantityInMT          = Math.Abs(otherDispatchAllocation.QuantityInMT);
                    loan.RemainingQuantityInMt = (otherDispatchAllocation.RemainingQuantityInMt);
                }
                LoanList.Add(loan);
            }
            return(LoanList);
        }