public List <HoldCargoViewModel> Match(List <HoldCargo> _holdcargo) { List <HoldCargoViewModel> _results = new List <HoldCargoViewModel>(); PackageNumberBL _packageNumberService = new PackageNumberBL(); StatusBL status = new StatusBL(); ReasonBL reason = new ReasonBL(); UserRoleBL user = new UserRoleBL(); ShipmentBL shipmentService = new ShipmentBL(); List <Shipment> shipList = shipmentService.GetAll(); UserStore _userService = new UserStore(); foreach (HoldCargo holdCargo in _holdcargo) { HoldCargoViewModel model = new HoldCargoViewModel(); //string _airwaybill = _packageNumberService.GetAll().Find(x => x.PackageNo == holdCargo.Cargo).Shipment.AirwayBillNo; HoldCargoViewModel isExist = _results.Find(x => x.AirwayBillNo == holdCargo.AirwayBillNo); if (isExist != null) { } else { model.Date = holdCargo.HoldCargoDate; model.AirwayBillNo = holdCargo.AirwayBillNo; Shipment ship = shipList.Find(x => x.AirwayBillNo == holdCargo.AirwayBillNo); if (ship != null) { model.Shipper = ship.Shipper.FullName; model.Consignee = ship.Consignee.FullName; model.Address = ship.Consignee.Address1; model.PaymentMode = ship.PaymentMode.PaymentModeName; model.ServiceMode = ship.ServiceMode.ServiceModeName; model.Status = status.GetById(holdCargo.StatusID).StatusName; // status.GetAll().Find(x => x.StatusID == holdCargo.StatusID).StatusName; model.Reason = reason.GetById(holdCargo.ReasonID).ReasonName; // .Find(x => x.ReasonID == holdCargo.ReasonID).ReasonName; model.EndorseBy = holdCargo.Endorsedby; //model.ScannedBy = user.GetActiveRoles().Find(x => x.RoleId == AppUser.User.UserId).RoleName; //model.ScannedBy = holdCargo.User.Employee.FullName; model.ScannedBy = "N/A"; string employee = _userService.FindById(holdCargo.CreatedBy).Employee.FullName; if (employee != "") { model.ScannedBy = employee; } //model.PreparedBy = user.GetAllUsers().Find(x => x.UserId == shi) model.Aging = Math.Round((DateTime.Now - holdCargo.HoldCargoDate).TotalDays, 2); model.Branch = holdCargo.User.Employee.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeName; _results.Add(model); } } } return(_results); }
public List <SegregationViewModel> Macth(List <Segregation> _segregation) { List <SegregationViewModel> _results = new List <SegregationViewModel>(); PackageNumberBL _packageNumberService = new PackageNumberBL(); ShipmentBL shipmentService = new ShipmentBL(); UserStore _userService = new UserStore(); foreach (Segregation segregation in _segregation) { SegregationViewModel model = new SegregationViewModel(); string _airwaybill = ""; try { _airwaybill = _packageNumberService.GetAll().Find(x => x.PackageNo == segregation.Cargo).Shipment.AirwayBillNo; } catch (Exception) { continue; } SegregationViewModel isExist = _results.Find(x => x.AirwayBillNo == _airwaybill); if (isExist != null) { isExist.Qty++; } else { model.BranchCorpOffice = segregation.BranchCorpOffice.BranchCorpOfficeName; model.Driver = segregation.Driver; model.Checker = segregation.Checker; model.PlateNo = segregation.PlateNo; model.Batch = segregation.Batch.BatchName; model.AirwayBillNo = _airwaybill; model.Qty++; model.Area = shipmentService.GetAll().Find(x => x.AirwayBillNo == _airwaybill).DestinationCity.CityName; model.CreatedDate = segregation.CreatedDate; //model.ScannedBy = AppUser.User.Employee.FullName; model.ScannedBy = "N/A"; string employee = _userService.FindById(segregation.CreatedBy).Employee.FullName; if (employee != "") { model.ScannedBy = employee; } _results.Add(model); } } return(_results); }
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); }