public bool ParseInboundCPM(string messageContent) { //method returns true if message has been created successfully //else returns false string[] splitMessageContent = messageContent .Split("\r\n", StringSplitOptions.None); if (this.flightDataValidation.IsCPMFlightDataValid(splitMessageContent)) { var inbound = this.flightService.GetInboundFlightByFlightNumber(this.GetFlightNumber(splitMessageContent[1])); string supplementaryInformation = this.ParseSupplementaryInformation(splitMessageContent[splitMessageContent.Length - 1]); int amountOfInboundContainers = this.parserCPMUtility.GetContainerCount(splitMessageContent); var listOfContainersForCurrentMessage = this.containerService.AddContainersToInboundFlight(inbound, amountOfInboundContainers); var listofContainerInfo = this.containerService.CreateContainerInfo(splitMessageContent, listOfContainersForCurrentMessage); var dto = new CPMDTO(listofContainerInfo, supplementaryInformation); this.messageService.CreateInboundCPM(inbound, dto); } else { return(false); } return(true); }
public void CreateInboundCPM(InboundFlight inbound, CPMDTO dto) { var inboundContainerPalletMessage = this.mapper.Map <ContainerPalletMessage>(dto); this.dbContext.ContainerPalletMessages.Add(inboundContainerPalletMessage); this.dbContext.SaveChanges(); inboundContainerPalletMessage.InboundFlight = inbound; inboundContainerPalletMessage.InboundFlightId = inbound.FlightId; }
public void CreateOutboundCPM(OutboundFlight outboundFlight, CPMDTO dto) { var outboundContainerPalletMessage = mapper.Map <ContainerPalletMessage>(dto); this.dbContext.ContainerPalletMessages.Add(outboundContainerPalletMessage); this.dbContext.SaveChanges(); outboundContainerPalletMessage.OutboundFlight = outboundFlight; outboundContainerPalletMessage.OutboundFlightId = outboundFlight.FlightId; outboundFlight.OutboundMessages.Add(outboundContainerPalletMessage); this.dbContext.SaveChanges(); }
public bool ParseOutboundCPM(string messageContent) { string[] splitMessageContent = messageContent .Split("\r\n", StringSplitOptions.None); if (this.flightDataValidation.IsCPMFlightDataValid(splitMessageContent)) { var outbound = this.flightService.GetOutboundFlightByFlightNumber(this.GetFlightNumber(splitMessageContent[1])); string supplementaryInformation = this.ParseSupplementaryInformation(splitMessageContent[splitMessageContent.Length - 1]); int amountOfInboundContainers = this.parserCPMUtility.GetContainerCount(splitMessageContent); var listOfContainersForCurrentMessage = this.containerService.AddContainersToOutboundFlight(outbound, amountOfInboundContainers); var listofContainerInfo = this.containerService.CreateContainerInfo(splitMessageContent, listOfContainersForCurrentMessage); var cpmDTO = new CPMDTO(listofContainerInfo, supplementaryInformation); this.messageService.CreateOutboundCPM(outbound, cpmDTO); } else { return(false); } return(true); }