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 <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); }