public List <DispatchDetailModelDto> ByDispatchIDetached(Guid dispatchId, string PreferedWeightMeasurment)
        {
            List <DispatchDetailModelDto> dispatchDetais = new List <DispatchDetailModelDto>();

            var query = _unitOfWork.DispatchDetailRepository.FindBy(t => t.DispatchID == dispatchId);

            ;

            foreach (var dispatchDetail in query)
            {
                var DDMD = new DispatchDetailModelDto();

                DDMD.DispatchID       = dispatchDetail.DispatchID;
                DDMD.DispatchDetailID = dispatchDetail.DispatchDetailID;
                DDMD.CommodityName    = dispatchDetail.Commodity.Name;
                DDMD.UnitName         = dispatchDetail.Unit.Name;

                DDMD.RequestedQuantityInUnit  = Math.Abs(dispatchDetail.RequestedQunatityInUnit);
                DDMD.DispatchedQuantityInUnit = Math.Abs(dispatchDetail.DispatchedQuantityInUnit);
                //TODO:Unit Measure comparison alert
                if (PreferedWeightMeasurment.ToUpperInvariant() == "QTL")
                {
                    DDMD.RequestedQuantityMT  = Math.Abs(dispatchDetail.RequestedQuantityInMT) * 10;
                    DDMD.DispatchedQuantityMT = Math.Abs(dispatchDetail.DispatchedQuantityInMT) * 10;
                }
                else
                {
                    DDMD.RequestedQuantityMT  = Math.Abs(dispatchDetail.RequestedQuantityInMT);
                    DDMD.DispatchedQuantityMT = Math.Abs(dispatchDetail.DispatchedQuantityInMT);
                }
                dispatchDetais.Add(DDMD);
            }
            return(dispatchDetais);
        }
        public List <DispatchDetailModelDto> ByDispatchIDetached(Guid dispatchId, string PreferedWeightMeasurment)
        {
            List <DispatchDetailModelDto> dispatchDetais = new List <DispatchDetailModelDto>();

            var query = (from rD in db.DispatchDetails
                         where rD.DispatchID == dispatchId
                         select rD);

            foreach (var dispatchDetail in query)
            {
                var DDMD = new DispatchDetailModelDto();

                DDMD.DispatchID       = dispatchDetail.DispatchID;
                DDMD.DispatchDetailID = dispatchDetail.DispatchDetailID;
                DDMD.CommodityName    = dispatchDetail.Commodity.Name;
                DDMD.UnitName         = dispatchDetail.Unit.Name;

                DDMD.RequestedQuantityInUnit  = Math.Abs(dispatchDetail.RequestedQunatityInUnit);
                DDMD.DispatchedQuantityInUnit = Math.Abs(dispatchDetail.DispatchedQuantityInUnit);

                if (PreferedWeightMeasurment.ToUpperInvariant() == "QN")
                {
                    DDMD.RequestedQuantityMT  = Math.Abs(dispatchDetail.RequestedQuantityInMT) * 10;
                    DDMD.DispatchedQuantityMT = Math.Abs(dispatchDetail.DispatchedQuantityInMT) * 10;
                }
                else
                {
                    DDMD.RequestedQuantityMT  = Math.Abs(dispatchDetail.RequestedQuantityInMT);
                    DDMD.DispatchedQuantityMT = Math.Abs(dispatchDetail.DispatchedQuantityInMT);
                }
                dispatchDetais.Add(DDMD);
            }
            return(dispatchDetais);
        }