public List <BundleViewModel> Match(List <Bundle> bundle)
        {
            PackageNumberBL        _packageNumberService = new PackageNumberBL();
            List <BundleViewModel> _results = new List <BundleViewModel>();
            ShipmentBL             shipment = new ShipmentBL();
            //UserBL _userService = new UserBL();
            UserStore _userService = new UserStore();

            foreach (Bundle _bundle in bundle)
            {
                BundleViewModel model       = new BundleViewModel();
                string          _airwaybill = "";
                try {
                    _airwaybill = _packageNumberService.FilterActive().Find(x => x.PackageNo == _bundle.Cargo).Shipment.AirwayBillNo;
                }catch (Exception) { continue; }

                BundleViewModel isExist = _results.Find(x => x.AirwayBillNo == _airwaybill);

                if (isExist != null)
                {
                    isExist.Qty++;
                    //_results.Add(isExist);
                }
                else
                {
                    model.AirwayBillNo = _airwaybill;
                    List <Shipment> list = shipment.FilterActive().Where(x => x.AirwayBillNo == _airwaybill).ToList();
                    foreach (Shipment ship in list)
                    {
                        model.Shipper       = ship.Shipper.FullName;
                        model.Consignee     = ship.Consignee.FullName;
                        model.Address       = ship.Consignee.Address1;
                        model.CommodityType = ship.Commodity.CommodityType.CommodityTypeName;
                        model.Commodity     = ship.Commodity.CommodityName;
                        model.Qty++;
                        model.AGW        += ship.Weight;
                        model.ServiceMode = ship.ServiceMode.ServiceModeName;
                        model.PaymendMode = ship.PaymentMode.PaymentModeName;
                        model.Area        = ship.OriginCity.CityName;
                        model.CreatedDate = ship.CreatedDate;
                        model.Destination = ship.DestinationCity.CityName;
                        model.BSO         = ship.OriginCity.CityName;
                    }
                    model.SackNo = _bundle.SackNo;
                    model.BCO    = _bundle.BranchCorpOffice.BranchCorpOfficeName;
                    //model.Scannedby = AppUser.User.Employee.FullName;
                    model.Scannedby = "N/A";
                    //string employee = _userService.FilterActive().Find(x => x.UserId == _bundle.CreatedBy).Employee.FullName;
                    string employee = _userService.FindById(_bundle.CreatedBy).Employee.FullName;
                    if (employee != "")
                    {
                        model.Scannedby = employee;
                    }
                    _results.Add(model);
                }
            }

            return(_results);
        }
Exemplo n.º 2
0
        public List <PickupCargoManifestViewModel> Match(List <Shipment> _shipment)
        {
            BranchAcceptanceBL branchAcceptanceBL        = new BranchAcceptanceBL();
            PackageNumberBL    _packageNumberService     = new PackageNumberBL();
            List <PickupCargoManifestViewModel> _results = new List <PickupCargoManifestViewModel>();

            List <PackageNumber> packageList = new List <PackageNumber>();
            int numberOfPackage = 0;

            foreach (Shipment shipment  in _shipment)
            {
                PickupCargoManifestViewModel model = new PickupCargoManifestViewModel();
                try {
                    packageList     = _packageNumberService.FilterActive().Where(x => x.ShipmentId == shipment.ShipmentId).Distinct().ToList();
                    numberOfPackage = packageList.Count;
                }
                catch (Exception) { continue; }
                foreach (PackageNumber number in packageList)
                {
                    List <BranchAcceptance> branchList = branchAcceptanceBL.FilterActive().Where(x => x.Cargo == number.PackageNo).Distinct().ToList();
                    foreach (BranchAcceptance branch in branchList)
                    {
                        model.Driver  = (branch.Driver != null || branch.Driver != "") ? branch.Driver : "N/A";
                        model.Checker = (branch.Checker != null || branch.Checker != "") ? branch.Checker : "N/A";
                    }
                }
                PickupCargoManifestViewModel isExist = _results.Find(x => x.AirwayBillNo == shipment.AirwayBillNo);

                if (isExist != null)
                {
                    isExist.QTY++;
                }
                else
                {
                    model.AirwayBillNo = shipment.AirwayBillNo;
                    model.Shipper      = shipment.Shipper.FullName;
                    model.Consignee    = shipment.Consignee.FullName;

                    model.ConsigneeAddress = shipment.Consignee.Address1 + " " + shipment.Consignee.Address2;
                    model.ShipperAddress   = shipment.Shipper.Address1 + " " + shipment.Shipper.Address2;
                    model.Commodity        = shipment.Commodity.CommodityName;
                    // model.QTY++;
                    model.QTY         = numberOfPackage;
                    model.AGW        += shipment.Weight;
                    model.ServiceMode = shipment.ServiceMode.ServiceModeName;
                    model.PaymentMode = shipment.PaymentMode.PaymentModeName;
                    model.Amount      = shipment.TotalAmount.ToString();
                    model.ScannedBy   = shipment.AcceptedBy.FullName;
                    try
                    {
                        model.Area = (shipment.Booking.AssignedToArea != null) ? shipment.Booking.AssignedToArea.City.CityName : "N/A";
                    }
                    catch (Exception)
                    {
                        model.Area = "N/A";
                    }
                    _results.Add(model);
                }
            }

            return(_results);
        }
Exemplo n.º 3
0
        public List <BranchAcceptanceViewModel> Match(List <BranchAcceptance> _branchAcceptances, List <Shipment> _shipments)
        {
            PackageNumberBL _packageNumberService = new PackageNumberBL();
            //BranchAcceptanceBL _branchAcceptanceService = new BranchAcceptanceBL();
            List <BranchAcceptanceViewModel> _results       = new List <BranchAcceptanceViewModel>();
            List <BranchAcceptanceViewModel> _resultsFilter = new List <BranchAcceptanceViewModel>();
            //UserBL _userService = new UserBL();
            UserStore _userService = new UserStore();

            foreach (Shipment shipment in _shipments)
            {
                BranchAcceptanceViewModel model           = new BranchAcceptanceViewModel();
                List <PackageNumber>      _packageNumbers = _packageNumberService.FilterActive().Where(x => x.ShipmentId == shipment.ShipmentId).ToList();

                foreach (PackageNumber packagenumber in _packageNumbers)
                {
                    BranchAcceptanceViewModel isAirawayBillExist = _results.Find(x => x.AirwayBillNo == shipment.AirwayBillNo);

                    BranchAcceptance _brachAcceptance = _branchAcceptances.Find(x => x.Cargo == packagenumber.PackageNo);


                    if (_brachAcceptance != null)
                    {
                        if (isAirawayBillExist != null)
                        {
                            isAirawayBillExist.TotalRecieved++;
                            isAirawayBillExist.Total = isAirawayBillExist.TotalRecieved;
                        }
                        else
                        {
                            model.AirwayBillNo = shipment.AirwayBillNo;

                            model.Area = "N/A";
                            if (shipment.Booking != null)
                            {
                                if (shipment.Booking.AssignedToArea != null)
                                {
                                    model.Area = shipment.Booking.AssignedToArea.RevenueUnitName;
                                }
                            }
                            model.Driver  = _brachAcceptance.Driver;
                            model.Checker = _brachAcceptance.Checker;
                            model.PlateNo = "N/A";
                            model.Batch   = _brachAcceptance.Batch.BatchName;
                            model.TotalRecieved++;
                            model.Total     = model.TotalRecieved;
                            model.CreatedBy = _brachAcceptance.CreatedDate;

                            model.BCO = _brachAcceptance.BranchCorpOffice.BranchCorpOfficeName;
                            model.BSO = "N/A";
                            if (shipment.Booking != null)
                            {
                                if (shipment.Booking.AssignedToArea != null)
                                {
                                    model.BSO = shipment.Booking.AssignedToArea.RevenueUnitName;
                                }
                            }
                            model.ScannedBy = "N/A";
                            //string employee = _userService.FilterActive().Find(x => x.UserId == _brachAcceptance.CreatedBy).Employee.FullName;
                            string employee = _userService.FindById(_brachAcceptance.CreatedBy).Employee.FullName;
                            if (employee != "")
                            {
                                model.ScannedBy = employee;
                            }

                            model.Remarks = shipment.Remarks;
                            model.Notes   = _brachAcceptance.Notes;
                            _results.Add(model);
                        }
                    }
                    else
                    {
                        if (isAirawayBillExist != null)
                        {
                            isAirawayBillExist.TotalDiscrepency++;
                            isAirawayBillExist.Total = isAirawayBillExist.TotalDiscrepency;
                        }
                        else
                        {
                            model.AirwayBillNo = shipment.AirwayBillNo;
                            model.Area         = "N/A";
                            if (shipment.Booking != null)
                            {
                                if (shipment.Booking.AssignedToArea != null)
                                {
                                    model.Area = shipment.Booking.AssignedToArea.RevenueUnitName;
                                }
                            }
                            model.Driver  = "N/A"; //_brachAcceptance.Driver;
                            model.Checker = "N/A"; //_brachAcceptance.Checker;
                            model.PlateNo = "N/A";
                            model.Batch   = "N/A"; //_brachAcceptance.Batch.BatchName;
                            model.TotalDiscrepency++;
                            model.Total = model.TotalDiscrepency;

                            model.BCO = "N/A"; //_brachAcceptance.BranchCorpOffice.BranchCorpOfficeName;
                            //model.BCO = shipment.Booking.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeName;
                            if (shipment.Booking != null)
                            {
                                if (shipment.Booking.AssignedToArea != null)
                                {
                                    model.BCO = shipment.Booking.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeName;
                                }
                            }


                            //model.BSO = "N/A"; //shipment.Booking.AssignedToArea.RevenueUnitName;
                            // model.BCO = _brachAcceptance.BranchCorpOffice.BranchCorpOfficeName;
                            model.BSO = "N/A";
                            if (shipment.Booking != null)
                            {
                                if (shipment.Booking.AssignedToArea != null)
                                {
                                    model.BSO = shipment.Booking.AssignedToArea.RevenueUnitName;
                                }
                            }
                            model.ScannedBy = "N/A";
                            //string employee = _userService.FilterActive().Find(x => x.UserId == _brachAcceptance.CreatedBy).Employee.FullName;
                            //if (employee != "")
                            //{
                            //    model.ScannedBy = employee;
                            //}
                            //model.Remarks = shipment.Remarks;
                            //model.Notes = _brachAcceptance.Notes;
                            _results.Add(model);
                        }
                    }
                }
            }

            //_resultsFilter = _results.GroupBy(d => new
            //{
            //    d.Area,
            //    d.Driver,
            //    d.Checker,
            //    d.PlateNo,
            //    d.Batch,
            //    d.AirwayBillNo,
            //    d.TotalRecieved,
            //    d.TotalDiscrepency,
            //    d.Total,
            //    d.Match,
            //    d.CreatedBy,
            //    d.BCO,
            //    d.BSO,
            //    d.ScannedBy,
            //    d.Remarks,
            //    d.Notes
            //})
            //                    .Select(d => d.First())
            //                    .ToList();
            return(_results);
            //return _resultsFilter;
        }
        public List <CargoTransferViewModel> Match(List <CargoTransfer> _cargoTransfers)
        {
            PackageNumberBL _packageNumberService = new PackageNumberBL();
            ShipmentBL      shipment = new ShipmentBL();
            List <CargoTransferViewModel> _results = new List <CargoTransferViewModel>();
            BundleBL      bundleService            = new BundleBL();
            PackageNumber _packageNumber           = new PackageNumber();
            List <string> listCargo    = new List <string>();
            UserStore     _userService = new UserStore();

            foreach (CargoTransfer cargoTransfer in _cargoTransfers)
            {
                CargoTransferViewModel model = new CargoTransferViewModel();
                string _airwaybill           = "";
                try {
                    // _airwaybill = _packageNumberService.GetAll().Find(x => x.PackageNo == cargoTransfer.Cargo).Shipment.AirwayBillNo;
                    _packageNumber = _packageNumberService.FilterActive().Where(x => x.PackageNo == cargoTransfer.Cargo).FirstOrDefault();
                    if (_packageNumber == null)
                    {
                        CargoTransferViewModel model1 = new CargoTransferViewModel();
                        listCargo = bundleService.GetAll().Where(x => x.SackNo == cargoTransfer.Cargo).Select(y => y.Cargo).ToList();
                        if (listCargo != null && listCargo.Count != 0)
                        {
                            CargoTransferViewModel isExist = _results.Find(x => x.AWB == cargoTransfer.Cargo);
                            if (isExist != null)
                            {
                                isExist.QTY++;
                                model.Pieces++;
                            }
                            else
                            {
                                //List<Shipment> list = shipment.GetAll().Where(x => x.AirwayBillNo.Equals(_airwaybill)).ToList();
                                //model1.Origin = _airwaybill;
                                //foreach (Shipment x in list)
                                //{
                                //    model1.Origin = x.OriginCity.CityName;
                                //    model1.Destination = x.DestinationCity.CityName;
                                //}
                                model1.Origin      = "N/A";
                                model1.Destination = "N/A";
                                model1.Driver      = cargoTransfer.Driver;
                                model1.Checker     = cargoTransfer.Checker;
                                model1.Pieces      = listCargo.Count;
                                model1.PlateNo     = cargoTransfer.PlateNo;
                                model1.Batch       = cargoTransfer.Batch.BatchName;
                                model1.AWB         = cargoTransfer.Cargo;
                                model1.QTY         = listCargo.Count;
                                model1.CreatedDate = cargoTransfer.CreatedDate;

                                model1.BCO       = cargoTransfer.BranchCorpOffice.BranchCorpOfficeName;
                                model1.GATEWAY   = cargoTransfer.RevenueUnit.RevenueUnitName;
                                model1.SATELLITE = cargoTransfer.RevenueUnit.RevenueUnitName;
                                //model1.ScannedBy = AppUser.User.Employee.FullName;
                                model1.ScannedBy = "N/A";
                                string employee = _userService.FindById(cargoTransfer.CreatedBy).Employee.FullName;
                                if (employee != "")
                                {
                                    model1.ScannedBy = employee;
                                }
                                _results.Add(model1);
                            }
                        }
                    }
                    else
                    {
                        _airwaybill = _packageNumber.Shipment.AirwayBillNo;
                        CargoTransferViewModel isExist = _results.Find(x => x.AWB == _airwaybill);

                        if (isExist != null)
                        {
                            isExist.QTY++;
                            model.Pieces++;
                            //_results.Add(isExist);
                        }
                        else
                        {
                            List <Shipment> list = shipment.GetAll().Where(x => x.AirwayBillNo.Equals(_airwaybill)).ToList();
                            model.Origin = _airwaybill;
                            foreach (Shipment x in list)
                            {
                                model.Origin      = x.OriginCity.CityName;
                                model.Destination = x.DestinationCity.CityName;
                                model.BCO         = x.DestinationCity.BranchCorpOffice.BranchCorpOfficeName;
                            }
                            model.Driver  = cargoTransfer.Driver;
                            model.Checker = cargoTransfer.Checker;
                            model.Pieces++;
                            model.PlateNo = cargoTransfer.PlateNo;
                            model.Batch   = cargoTransfer.Batch.BatchName;
                            model.AWB     = _airwaybill;
                            model.QTY++;
                            model.CreatedDate = cargoTransfer.CreatedDate;

                            // model.BCO = cargoTransfer.BranchCorpOffice.BranchCorpOfficeName;
                            //model.BCO = cargoTransfer.BranchCorpOffice.BranchCorpOfficeName;
                            model.GATEWAY   = cargoTransfer.RevenueUnit.RevenueUnitName;
                            model.SATELLITE = cargoTransfer.RevenueUnit.RevenueUnitName;
                            //model.ScannedBy = AppUser.User.Employee.FullName;
                            model.ScannedBy = "N/A";
                            string employee = _userService.FindById(cargoTransfer.CreatedBy).Employee.FullName;
                            if (employee != "")
                            {
                                model.ScannedBy = employee;
                            }
                            _results.Add(model);
                        }
                    }
                }
                catch (Exception) { continue; }
            }
            return(_results);
        }
        public List <GatewayInboundViewModel> Match(List <GatewayInbound> _inbound)
        {
            PackageNumberBL _packageNumberService   = new PackageNumberBL();
            List <GatewayInboundViewModel> _results = new List <GatewayInboundViewModel>();
            PackageNumber _packageNumber            = new PackageNumber();
            BundleBL      bundleService             = new BundleBL();
            List <string> listCargo    = new List <string>();
            UserStore     _userService = new UserStore();

            foreach (GatewayInbound inbound in _inbound)
            {
                GatewayInboundViewModel model = new GatewayInboundViewModel();
                string _airwaybill            = "";
                try {
                    // _airwaybill = _packageNumberService.GetAll().Find(x => x.PackageNo == inbound.Cargo).Shipment.AirwayBillNo;
                    _packageNumber = _packageNumberService.FilterActive().Where(x => x.PackageNo == inbound.Cargo).FirstOrDefault();
                    if (_packageNumber == null)
                    {
                        GatewayInboundViewModel model1 = new GatewayInboundViewModel();
                        listCargo = bundleService.GetAll().Where(x => x.SackNo == inbound.Cargo).Select(y => y.Cargo).ToList();
                        if (listCargo != null && listCargo.Count != 0)
                        {
                            GatewayInboundViewModel isExist = _results.Find(x => x.AirwayBillNo == inbound.Cargo);
                            if (isExist != null)
                            {
                                isExist.Pieces++;
                            }
                            else
                            {
                                model1.AirwayBillNo  = inbound.Cargo;
                                model1.Gateway       = inbound.Gateway;
                                model1.Origin        = inbound.BranchCorpOffice.BranchCorpOfficeName;
                                model1.Pieces        = listCargo.Count;
                                model1.MAWB          = inbound.MasterAirwayBill;
                                model1.FlightNo      = inbound.FlightNumber;
                                model1.CommodityType = inbound.CommodityType.CommodityTypeName;
                                model1.CreatedDate   = inbound.CreatedDate;
                                //model1.ScannedBy = AppUser.User.Employee.FullName;
                                model1.ScannedBy = "N/A";
                                string employee = _userService.FindById(inbound.CreatedBy).Employee.FullName;
                                if (employee != "")
                                {
                                    model1.ScannedBy = employee;
                                }
                                _results.Add(model1);
                            }
                        }
                    }
                    else
                    {
                        _airwaybill = _packageNumber.Shipment.AirwayBillNo;

                        GatewayInboundViewModel isExist = _results.Find(x => x.AirwayBillNo == _airwaybill);
                        if (isExist != null)
                        {
                            isExist.Pieces++;
                        }
                        else
                        {
                            model.AirwayBillNo = _airwaybill;
                            model.Gateway      = inbound.Gateway;
                            model.Origin       = inbound.BranchCorpOffice.BranchCorpOfficeName;
                            model.Pieces++;
                            model.MAWB          = inbound.MasterAirwayBill;
                            model.FlightNo      = inbound.FlightNumber;
                            model.CommodityType = inbound.CommodityType.CommodityTypeName;
                            model.CreatedDate   = inbound.CreatedDate;
                            //model.ScannedBy = AppUser.User.Employee.FullName;
                            model.ScannedBy = "N/A";
                            string employee = _userService.FindById(inbound.CreatedBy).Employee.FullName;
                            if (employee != "")
                            {
                                model.ScannedBy = employee;
                            }
                            _results.Add(model);
                        }
                    }
                }
                catch (Exception) { continue; }
            }


            return(_results);
        }
Exemplo n.º 6
0
        public List <GatewayOutboundViewModel> Match(List <GatewayInbound> _inbound, List <GatewayOutbound> _outbound)
        {
            PackageNumberBL _packageNumberService    = new PackageNumberBL();
            List <GatewayOutboundViewModel> _results = new List <GatewayOutboundViewModel>();
            PackageNumber _packageNumber             = new PackageNumber();
            List <string> listCargo     = new List <string>();
            BundleBL      bundleService = new BundleBL();
            UserStore     _userService  = new UserStore();

            foreach (GatewayOutbound outbound in _outbound)
            {
                GatewayOutboundViewModel model = new GatewayOutboundViewModel();
                string _airwaybill             = "";
                try {
                    //_airwaybill = _packageNumberService.GetAll().Find(x => x.PackageNo == outbound.Cargo).Shipment.AirwayBillNo;
                    _packageNumber = _packageNumberService.FilterActive().Where(x => x.PackageNo == outbound.Cargo).FirstOrDefault();
                    if (_packageNumber == null)
                    {
                        GatewayOutboundViewModel model1 = new GatewayOutboundViewModel();
                        listCargo = bundleService.GetAll().Where(x => x.SackNo == outbound.Cargo).Select(y => y.Cargo).ToList();
                        if (listCargo != null && listCargo.Count != 0)
                        {
                            GatewayOutboundViewModel isExist = _results.Find(x => x.AirwayBillNo == outbound.Cargo);
                            if (_inbound.Exists(x => x.Cargo == outbound.Cargo))
                            {
                                if (isExist != null)
                                {
                                    isExist.TotalRecieved++;
                                    isExist.Total = isExist.TotalRecieved;
                                }
                                else
                                {
                                    model1.AirwayBillNo  = outbound.Cargo;
                                    model1.Gateway       = outbound.Gateway;
                                    model1.Driver        = outbound.Driver;
                                    model1.PlateNo       = outbound.PlateNo;
                                    model1.Batch         = outbound.Batch.BatchName;
                                    model1.TotalRecieved = listCargo.Count;
                                    model1.Total         = model1.TotalRecieved;
                                    model1.Branch        = outbound.BranchCorpOffice.BranchCorpOfficeName;
                                    // model1.ScannedBy = AppUser.User.Employee.FullName;
                                    model1.ScannedBy = "N/A";
                                    //string employee = _userService.FilterActive().Find(x => x.UserId == _bundle.CreatedBy).Employee.FullName;
                                    string employee = _userService.FindById(outbound.CreatedBy).Employee.FullName;
                                    if (employee != "")
                                    {
                                        model1.ScannedBy = employee;
                                    }
                                    model1.CommodityTypeName = "N/A";
                                    //model1.CommodityTypeName = _packageNumberService.FilterActiveBy(x => x.PackageNo == outbound.Cargo).First().Shipment.CommodityType.CommodityTypeName;
                                    _results.Add(model1);
                                }
                            }
                            else
                            {
                                if (isExist != null)
                                {
                                    isExist.TotalDiscrepency++;
                                    isExist.Total = isExist.TotalDiscrepency;
                                }
                                else
                                {
                                    model1.AirwayBillNo     = outbound.Cargo;
                                    model1.Gateway          = outbound.Gateway;
                                    model1.Driver           = outbound.Driver;
                                    model1.PlateNo          = outbound.PlateNo;
                                    model1.Batch            = outbound.Batch.BatchName;
                                    model1.TotalDiscrepency = listCargo.Count;
                                    model1.Total            = model1.TotalDiscrepency;
                                    model1.Branch           = outbound.BranchCorpOffice.BranchCorpOfficeName;
                                    //model1.ScannedBy = "N/A";
                                    string employee = _userService.FindById(outbound.CreatedBy).Employee.FullName;
                                    if (employee != "")
                                    {
                                        model1.ScannedBy = employee;
                                    }
                                    model1.CommodityTypeName = "N/A";
                                    //model1.CommodityTypeName = _packageNumberService.FilterActiveBy(x => x.PackageNo == outbound.Cargo).First().Shipment.CommodityType.CommodityTypeName;
                                    _results.Add(model1);
                                }
                            }
                        }
                    }
                    else
                    {
                        _airwaybill = _packageNumber.Shipment.AirwayBillNo;
                        GatewayOutboundViewModel isExist = _results.Find(x => x.AirwayBillNo == _airwaybill);
                        if (_inbound.Exists(x => x.Cargo == outbound.Cargo))
                        {
                            if (isExist != null)
                            {
                                isExist.TotalRecieved++;
                                isExist.Total = isExist.TotalRecieved;
                                //model.Total = model.TotalRecieved;
                                //_results.Add(isExist);
                            }
                            else
                            {
                                model.AirwayBillNo = _airwaybill;
                                model.Gateway      = outbound.Gateway;
                                model.Driver       = outbound.Driver;
                                model.PlateNo      = outbound.PlateNo;
                                model.Batch        = outbound.Batch.BatchName;
                                model.TotalRecieved++;
                                model.Total  = model.TotalRecieved;
                                model.Branch = outbound.BranchCorpOffice.BranchCorpOfficeName;
                                //model.ScannedBy = AppUser.User.Employee.FullName;
                                string employee = _userService.FindById(outbound.CreatedBy).Employee.FullName;
                                if (employee != "")
                                {
                                    model.ScannedBy = employee;
                                }
                                //model.CommodityTypeName = _inbound.Where(x => x.Cargo == outbound.Cargo).Select(x => x.CommodityType.CommodityTypeName).ToString();
                                // model.CommodityTypeName = _inbound.Find(x => x.Cargo == outbound.Cargo).CommodityType.CommodityTypeName;
                                model.CommodityTypeName = _packageNumberService.FilterActiveBy(x => x.PackageNo == outbound.Cargo).First().Shipment.CommodityType.CommodityTypeName;
                                _results.Add(model);
                            }
                        }
                        else
                        {
                            if (isExist != null)
                            {
                                isExist.TotalDiscrepency++;
                                isExist.Total = isExist.TotalDiscrepency;
                                //model.Total = model.TotalDiscrepency;
                                //_results.Add(isExist);
                            }
                            else
                            {
                                model.AirwayBillNo = _airwaybill;
                                model.Gateway      = outbound.Gateway;
                                model.Driver       = outbound.Driver;
                                model.PlateNo      = outbound.PlateNo;
                                model.Batch        = outbound.Batch.BatchName;
                                model.TotalDiscrepency++;
                                model.Total  = model.TotalDiscrepency;
                                model.Branch = outbound.BranchCorpOffice.BranchCorpOfficeName;
                                string employee = _userService.FindById(outbound.CreatedBy).Employee.FullName;
                                if (employee != "")
                                {
                                    model.ScannedBy = employee;
                                }
                                //model.CommodityTypeName = _inbound.Find(x => x.Cargo == outbound.Cargo).CommodityType.CommodityTypeName;
                                // model.CommodityTypeName = _inbound.Where(x => x.Cargo == outbound.Cargo).Select(x => x.CommodityType.CommodityTypeName).ToString();
                                model.CommodityTypeName = _packageNumberService.FilterActiveBy(x => x.PackageNo == outbound.Cargo).First().Shipment.CommodityType.CommodityTypeName;
                                _results.Add(model);
                            }
                        }
                    }
                }
                catch (Exception) { continue; }
            }


            return(_results);
        }
        public List <UnbundleViewModel> Match(List <Unbundle> _unbundle, List <Bundle> _bundle)
        {
            BranchCorpOfficeBL       bcoService            = new BranchCorpOfficeBL();
            PackageNumberBL          _packageNumberService = new PackageNumberBL();
            List <UnbundleViewModel> _results = new List <UnbundleViewModel>();
            ShipmentBL shipment     = new ShipmentBL();
            Shipment   _shipment    = new Shipment();
            UserStore  _userService = new UserStore();
            //string bcoName = bcoService.FilterActive().Find(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).BranchCorpOfficeName;
            string bcoName = "";
            Guid   bcoid;
            Guid   userid;

            foreach (Bundle bundle in _bundle)
            {
                UnbundleViewModel model = new UnbundleViewModel();
                try
                {
                    _shipment = _packageNumberService.FilterActive().Find(x => x.PackageNo == bundle.Cargo).Shipment;
                }
                catch (Exception ex)
                {
                    Logs.ErrorLogs("", "Unbundle Match", ex.Message);
                    continue;
                }
                UnbundleViewModel isExist = _results.Find(x => x.AirwayBillNo == _shipment.AirwayBillNo);

                if (_unbundle.Exists(x => x.Cargo == bundle.Cargo))
                {
                    if (isExist != null)
                    {
                        isExist.ScannedPcs++;
                        //isExist.TotalPcs += isExist.ScannedPcs;
                        isExist.TotalPcs = isExist.ScannedPcs;
                    }

                    else
                    {
                        model.AirwayBillNo = _shipment.AirwayBillNo;
                        model.SackNo       = bundle.SackNo;
                        model.ScannedPcs++;
                        model.Weight     += bundle.Weight;
                        model.TotalPcs    = model.ScannedPcs;
                        model.Origin      = _shipment.OriginCity.CityName;
                        model.CreatedDate = bundle.CreatedDate;
                        model.Branch      = "N/A";
                        bcoid             = _unbundle.Find(x => x.Cargo == bundle.Cargo).BranchCorpOfficeID;
                        if (bcoid != null && bcoid != Guid.Empty)
                        {
                            bcoName      = bcoService.FilterActive().Find(x => x.BranchCorpOfficeId == bcoid).BranchCorpOfficeName;
                            model.Branch = bcoName;
                        }
                        //model.ScannedBy = AppUser.User.Employee.FullName;
                        model.ScannedBy = "N/A";
                        userid          = _unbundle.Find(x => x.Cargo == bundle.Cargo).CreatedBy;
                        string employee = _userService.FindById(userid).Employee.FullName;
                        if (employee != "")
                        {
                            model.ScannedBy = employee;
                        }
                        _results.Add(model);
                    }
                }
                else
                {
                    if (isExist != null)
                    {
                        isExist.TotalDiscrepency++;
                        //isExist.TotalPcs += isExist.TotalDiscrepency;
                        isExist.TotalPcs = isExist.TotalDiscrepency;
                    }

                    else
                    {
                        model.AirwayBillNo = _shipment.AirwayBillNo;
                        model.SackNo       = bundle.SackNo;
                        model.TotalDiscrepency++;
                        model.TotalPcs = model.TotalDiscrepency;
                        model.Weight  += bundle.Weight;

                        model.Origin      = _shipment.OriginCity.CityName;
                        model.CreatedDate = bundle.CreatedDate;
                        model.Branch      = "N/A";
                        bcoName           = _packageNumberService.FilterActive().Find(x => x.PackageNo == bundle.Cargo).Shipment.OriginCity.BranchCorpOffice.BranchCorpOfficeName;
                        if (bcoName != "")
                        {
                            //bcoName = bcoService.FilterActive().Find(x => x.BranchCorpOfficeId == bcoid).BranchCorpOfficeName;
                            model.Branch = bcoName;
                        }
                        //model.Branch = bundle.BranchCorpOffice.BranchCorpOfficeName;
                        model.ScannedBy = "N/A";
                        _results.Add(model);
                    }
                }
            }
            return(_results);
        }