private void fillImportAgentDetail(TradelaneManifestReport reportModel, int userId) { var userDetail = new FrayteUserRepository().GetInternalUserDetail(userId); if (userDetail != null && userDetail.UserAddress != null) { reportModel.ImportAgent = string.Empty; if (!string.IsNullOrEmpty(userDetail.ContactName)) { reportModel.ImportAgent += userDetail.ContactName; } if (!string.IsNullOrEmpty(userDetail.CompanyName)) { reportModel.ImportAgent += Environment.NewLine + userDetail.ContactName; } if (!string.IsNullOrEmpty(userDetail.UserAddress.Address)) { reportModel.ImportAgent += Environment.NewLine + userDetail.UserAddress.Address; } if (!string.IsNullOrEmpty(userDetail.UserAddress.Address2)) { reportModel.ImportAgent += Environment.NewLine + userDetail.UserAddress.Address2; } if (!string.IsNullOrEmpty(userDetail.UserAddress.City)) { reportModel.ImportAgent += Environment.NewLine + userDetail.UserAddress.City; } if (!string.IsNullOrEmpty(userDetail.UserAddress.Zip)) { reportModel.ImportAgent += Environment.NewLine + userDetail.UserAddress.Zip; } if (!string.IsNullOrEmpty(userDetail.UserAddress.State)) { reportModel.ImportAgent += Environment.NewLine + userDetail.UserAddress.State; } if (!string.IsNullOrEmpty(userDetail.UserAddress.Country.Name)) { reportModel.ImportAgent += Environment.NewLine + userDetail.UserAddress.Country.Name; } if (!string.IsNullOrEmpty(userDetail.TelephoneNo)) { reportModel.ImportAgent += Environment.NewLine + "(" + userDetail.UserAddress.Country.CountryPhoneCode + ") " + userDetail.TelephoneNo; } } else { reportModel.ImportAgent = ""; } }
private void fillImportPackageDetail(TradelaneManifestReport reportModel, TradelaneBooking shipmentDetail) { reportModel.ShipmentDetail = new List <TradelaneManifestReportDetail>(); TradelaneManifestReportDetail detail; foreach (var item in shipmentDetail.HAWBPackages) { detail = new TradelaneManifestReportDetail(); detail.HAWB = item.HAWB; detail.TotalWeight = item.TotalWeight.ToString() + " " + (shipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? "KG" : "LB"); detail.TotalVolume = Math.Round(item.TotalVolume, 2).ToString() + " " + (shipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? "CM3" : "IN3"); detail.TotalCarton = item.TotalCartons.ToString() + " CTN"; detail.BillNumbers = item.HAWB + Environment.NewLine + Environment.NewLine + "Col HBL: " + string.Empty + Environment.NewLine + "Shipper Ref: " + shipmentDetail.ShipperAdditionalNote; detail.Shipper = shipmentDetail.ShipFrom.CompanyName; detail.Receiver = shipmentDetail.ShipTo.CompanyName; detail.Origin = shipmentDetail.DepartureAirport.AirportCode; detail.Destination = shipmentDetail.DestinationAirport.AirportCode; detail.ShipmentDescription = shipmentDetail.ShipmentDescription; reportModel.ShipmentDetail.Add(detail); } }
public List <TradelaneManifestReport> ManifestReportModel(int tradelaneShipmentId, int userId) { List <TradelaneManifestReport> list = new List <TradelaneManifestReport>(); TradelaneManifestReport reportModel = new TradelaneManifestReport(); TradelaneBooking shipmentDetail = new TradelaneBookingRepository().GetTradelaneBookingDetails(tradelaneShipmentId, ""); if (shipmentDetail != null) { if (userId > 0) { reportModel.PrintedBy = dbContext.Users.Find(userId).ContactName; } else { reportModel.PrintedBy = dbContext.Users.Find(shipmentDetail.CreatedBy).ContactName; } if (!string.IsNullOrEmpty(reportModel.MAWB)) { reportModel.MAWB = shipmentDetail.AirlinePreference.AilineCode + " " + shipmentDetail.MAWB.Substring(0, 4) + " " + shipmentDetail.MAWB.Substring(4, 4); } else { reportModel.MAWB = ""; } reportModel.FrayteNumber = shipmentDetail.FrayteNumber; reportModel.AirlineCode = shipmentDetail.AirlinePreference.AilineCode; reportModel.Console = string.Empty; reportModel.CreatedOn = DateTime.UtcNow; reportModel.Arrival = string.Empty; if (shipmentDetail.ShipmentHandlerMethod.ShipmentHandlerMethodId != 5) { if (shipmentDetail.MAWBAgentId.HasValue && shipmentDetail.MAWBAgentId.Value > 0) { var allocation = dbContext.TradelaneShipmentAllocations.Where(p => p.TradelaneShipmentId == tradelaneShipmentId).FirstOrDefault(); if (allocation != null) { if (allocation.EstimatedDateofDelivery.HasValue && !string.IsNullOrEmpty(allocation.FlightNumber)) { reportModel.FlightAndDate = allocation.FlightNumber + " / " + shipmentDetail.DepartureAirport.AirportCode + " / " + allocation.EstimatedDateofDelivery.Value.ToString("dd-MMM-yy"); } reportModel.ETD = allocation.EstimatedDateofDelivery; reportModel.ETA = allocation.EstimatedDateofArrival; fillExportAgentDetail(reportModel, shipmentDetail.MAWBAgentId.Value); reportModel.ImportAgent = ""; } else { reportModel.ImportAgent = ""; reportModel.ExportAgent = ""; } } else { reportModel.ImportAgent = ""; reportModel.ExportAgent = ""; } } else { var shipmentAllocation = dbContext.TradelaneShipmentAllocations.Where(p => p.TradelaneShipmentId == tradelaneShipmentId).ToList(); if (shipmentAllocation.Count > 1) { var allocation = shipmentAllocation.Where(p => p.LegNum == "Leg1").FirstOrDefault(); if (allocation.EstimatedDateofDelivery.HasValue && !string.IsNullOrEmpty(allocation.FlightNumber)) { reportModel.FlightAndDate = allocation.FlightNumber + " / " + shipmentDetail.DepartureAirport.AirportCode + " / " + allocation.EstimatedDateofDelivery.Value.ToString("dd-MMM-yy"); } int ExportAgent = shipmentAllocation.Where(p => p.LegNum == "Leg1").FirstOrDefault().AgentId.Value; int ImportAgent = shipmentAllocation.Where(p => p.LegNum == "Leg2").FirstOrDefault().AgentId.Value; fillExportAgentDetail(reportModel, ExportAgent); fillImportAgentDetail(reportModel, ImportAgent); } else { reportModel.ExportAgent = ""; reportModel.ImportAgent = ""; } } reportModel.Loading = shipmentDetail.DepartureAirport.AirportCode; reportModel.DisCharge = shipmentDetail.DestinationAirport.AirportCode; reportModel.TotalPackages = shipmentDetail.HAWBPackages.Sum(p => p.PackagesCount); reportModel.TotalVolume = Math.Round(shipmentDetail.HAWBPackages.Sum(p => p.TotalVolume), 2).ToString() + " " + (shipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? "CM3" : "IN3"); reportModel.TotalWeight = shipmentDetail.HAWBPackages.Sum(p => p.TotalWeight).ToString() + " " + (shipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? "KG" : "LB"); reportModel.TotalCartons = shipmentDetail.HAWBPackages.Sum(p => p.TotalCartons); reportModel.TotalShipments = shipmentDetail.HAWBPackages.Count(); fillImportPackageDetail(reportModel, shipmentDetail); } list.Add(reportModel); return(list); }