public bool ParseOutboundLDM(string messageContent) { string[] splitMessage = messageContent .Split("\r\n", StringSplitOptions.None); if (this.flightDataValidation.IsLDMFlightDataValid(splitMessage)) { var ldmFlightInfoMatch = ldmFlightInfoRegex.Match(splitMessage[1]); if (ldmFlightInfoMatch.Success) { string outboundFlightNumber = ldmFlightInfoMatch.Groups["flt"].Value; string crewConfiguration = ldmFlightInfoMatch.Groups["crewConfig"].Value; var loadMatch = loadDistributionRegex.Match(splitMessage[2]); if (loadMatch.Success) { int[] paxFigures = this.ParsePAXFigures(splitMessage[2]); int totalWeightInCompartments = this.ParseLDMTotalWeight(loadMatch.Groups["ttlWghtInCpt"].Value); var weightInEachCompartment = this.ParseWeightsInCompartments(loadMatch.Groups["wghtByCompartment"].Value); var loadSummaryMatch = loadSummaryRegex.Match(splitMessage[3]); if (loadSummaryMatch.Success) { int[] loadSummaryInfo = this.ParseLoadSummaryInfo(splitMessage[3]); var outboundFlight = this.flightService.GetOutboundFlightByFlightNumber(outboundFlightNumber); if (outboundFlight != null) { var dto = new LDMDTO(crewConfiguration, paxFigures, totalWeightInCompartments, weightInEachCompartment, loadSummaryInfo); this.messageService.CreateOutboundLDM(outboundFlight, dto); } else { return(false); } } else { return(false); } } else { return(false); } } else { return(false); } } else { return(false); } return(true); }
public void CreateOutboundLDM(OutboundFlight outboundFlight, LDMDTO dto) { var outboundLoadDistributionMessage = this.mapper.Map <LoadDistributionMessage>(dto); this.dbContext.LoadDistributionMessages.Add(outboundLoadDistributionMessage); this.dbContext.SaveChanges(); outboundLoadDistributionMessage.OutboundFlight = outboundFlight; outboundLoadDistributionMessage.OutboundFlightId = outboundFlight.FlightId; this.dbContext.SaveChanges(); }
public void CreateInboundLDM(InboundFlight inboundFlight, LDMDTO ldmDTO) { var loadDistributionMessage = mapper.Map <LoadDistributionMessage>(ldmDTO); this.dbContext.LoadDistributionMessages.Add(loadDistributionMessage); this.dbContext.SaveChanges(); loadDistributionMessage.InboundFlight = inboundFlight; loadDistributionMessage.InboundFlightId = inboundFlight.FlightId; this.dbContext.SaveChanges(); }