public List <DailyTripViewModel> Match(List <Distribution> _distribution) { List <DailyTripViewModel> _results = new List <DailyTripViewModel>(); PackageNumberBL _packageNumberService = new PackageNumberBL(); UserStore _userService = new UserStore(); // ShipmentBL shipmentService = new ShipmentBL(); foreach (Distribution distribution in _distribution) { DailyTripViewModel model = new DailyTripViewModel(); string _airwaybill = ""; try { _airwaybill = _packageNumberService.GetAll().Find(x => x.ShipmentId == distribution.ShipmentId).Shipment.AirwayBillNo; } catch (Exception) { continue; } DailyTripViewModel isExist = _results.Find(x => x.AirwayBillNo == _airwaybill); if (isExist != null) { isExist.Qty++; isExist.Amount += distribution.Amount; } else { model.AirwayBillNo = _airwaybill; model.Qty++; model.Consignee = distribution.Consignee.FullName; model.Address = distribution.Consignee.Address1 + " " + distribution.Consignee.Address2; model.AGW += distribution.Shipment.Weight; model.ServiceMode = distribution.ServiceMode.ServiceModeName; model.PaymentMode = distribution.PaymentMode.PaymentModeName; model.Amount += distribution.Amount; //model.Area = distribution.Area.RevenueUnitName; model.Driver = distribution.Driver; model.Checker = distribution.Checker; //model.BCO = distribution.Area. model.PaymentCode = distribution.PaymentMode.PaymentModeCode; //model.Scannedby = AppUser.User.Employee.FullName; model.Scannedby = "N/A"; string employee = _userService.FindById(distribution.CreatedBy).Employee.FullName; if (employee != "") { model.Scannedby = employee; } model.BatchName = distribution.Batch.BatchName; _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); }