//public int Invoke(DateTime processStart, DateTime gasDay, string cycle, string fileName, NaesbQuickResponse nqr)
        //{
        ////serialize Naesb NaesbRequestForConfirmation
        //XmlDocument naesbXml = XmlTransformer.XmlSerialize(nqr, true);

        ////create naesb event process
        //int eventProcessId = _naesbEventProcessCreateService.Invoke(
        //    new NaesbEventProcess
        //    {
        //        Type = "QR",
        //        GasDay = gasDay,
        //        Cycle = cycle,
        //        Pipeline = _naesbPipelineGetService.Invoke(nqr.PartyIndentificaton.ConfirmingPartyDuns).Pipeline,
        //        Utility = _naesbUtilityGetService.Invoke(nqr.PartyIndentificaton.UtilityDunsNumber).Utility,
        //        ProcessStart = processStart,
        //        EdiFileName = fileName,
        //        EdiData = naesbXml.InnerXml,
        //        DomainData = null,
        //        UserId = _settings.UserId
        //    }
        //);

        ////TODO: maybe make this use its own class instead of generic -> NaesbEventProcessCompletion
        ////update ProcessEnd timestamp
        //_naesbEventProcessUpdateService.Invoke(eventProcessId, new KeyValuePair<string, DateTime>("ProcessEnd", DateTime.Now));

        //return eventProcessId;
        //}

        public int Invoke(DateTime processStart, string fileName, Domain.ConfirmationResponse.ConfirmationResponse cr)
        {
            //transform ConfirmationResponse
            NaesbQuickResponse nqr = _naesbQuickResponseGetService.Invoke(cr);

            //serialize Naesb NaesbRequestForConfirmation
            XmlDocument naesbXml = XmlTransformer.XmlSerialize(nqr, true);

            //create naesb event process
            int eventProcessId = _naesbEventProcessCreateService.Invoke(
                new NaesbEventProcess
            {
                Type         = "QR",
                GasDay       = cr.GasDay,
                Cycle        = cr.Cycle,
                Pipeline     = cr.PartyIndentificaton.PipelineEntity,
                Utility      = cr.PartyIndentificaton.UtilityEntity,
                ProcessStart = processStart,
                EdiFileName  = fileName,
                EdiData      = naesbXml.InnerXml,
                DomainData   = null,    // there is no business QuickResponse
                UserId       = _settings.UserId
            }
                );

            //TODO: maybe make this use its own class instead of generic -> NaesbEventProcessCompletion
            //update ProcessEnd timestamp
            _naesbEventProcessUpdateService.Invoke(eventProcessId, new KeyValuePair <string, DateTime>("ProcessEnd", DateTime.Now));

            return(eventProcessId);
        }
        public int Invoke(DateTime processStart, string fileName, Domain.RequestForConfirmation.RequestForConfirmation obj)
        {
            //map domain rfc model to the Naesb rfc model.
            NaesbRequestForConfirmation nrfc = _naesbRequestForConfirmationGetService.Invoke(obj);

            //serialize to xml
            XmlDocument domainXml = XmlTransformer.XmlSerialize(obj, true);
            //serialize Naesb NaesbRequestForConfirmation
            XmlDocument naesbXml = XmlTransformer.XmlSerialize(nrfc, true);

            //create naesb event process
            int eventProcessId = _naesbEventProcessCreateService.Invoke(
                new NaesbEventProcess
            {
                Type         = "RFC",
                GasDay       = obj.GasDay,
                Cycle        = obj.Cycle,
                Pipeline     = obj.PartyIndentificaton.PipelineEntity,
                Utility      = obj.PartyIndentificaton.UtilityEntity,
                ProcessStart = processStart,
                EdiFileName  = fileName,
                EdiData      = naesbXml.InnerXml,
                DomainData   = domainXml.InnerXml,
                UserId       = _settings.UserId
            }
                );

            //get the naesb event
            var naesbEvent = _naesbEventGetService.Invoke("RFC", obj.PartyIndentificaton.PipelineEntity, obj.PartyIndentificaton.UtilityEntity, obj.Cycle);

            if (naesbEvent != null && naesbEvent.On == true) //if null then the pipeline/utility/cycle doesn't exist in Pegasys
            {
                //save the domain rfc to the repository
                _requestForConfirmationEventCreateService.Invoke(obj);

                //TODO: maybe make this use its own class instead of generic -> NaesbEventProcessCompletion
                //update ProcessEnd timestamp
                _naesbEventProcessUpdateService.Invoke(eventProcessId, new KeyValuePair <string, DateTime>("ProcessEnd", DateTime.Now));

                return(eventProcessId);
            }

            throw new NaesbError
                  {
                      ReasonCode = "101",
                      Value      = "Pipeline/Utility/Cycle naesb event not found."
                  };
        }
        private int CreateConfirmationResponse(DateTime processStart, string fileName, NaesbConfirmationResponse naesbObj, XmlDocument naesbXml)
        {
            //map NaesbConfirmationResponse to ConfirmationResponse
            Nomination.Domain.ConfirmationResponse.ConfirmationResponse cr = _confirmationResponseGetService.Invoke(naesbObj);

            //serialize to xml
            XmlDocument domainXml = CS.Common.Utilities.XmlTransformer.XmlSerialize(cr, true);

            //instantiate naesb event process
            NaesbEventProcess obj = new NaesbEventProcess
            {
                Type         = "CR",
                GasDay       = cr.GasDay,
                Cycle        = cr.Cycle,
                Pipeline     = cr.PartyIndentificaton.PipelineEntity,
                Utility      = cr.PartyIndentificaton.UtilityEntity,
                ProcessStart = processStart,
                EdiFileName  = fileName,
                EdiData      = naesbXml.InnerXml,
                DomainData   = domainXml.InnerXml,
                UserId       = _settings.UserId
            };

            //get the naesb event
            var naesbEvent = _naesbEventGetService.Invoke("CR", obj.Pipeline, obj.Utility, obj.Cycle);

            if (naesbEvent != null && naesbEvent.On == true) //if null then the pipeline/utility/cycle doesn't exist in Pegasys
            {
                //create naesb event process
                int eventProcessId = _naesbEventProcessCreateService.Invoke(obj);

                //create the ConfirmationResponse
                _confirmationResponseCreateService.Invoke(cr);

                //TODO: maybe make this use its own class instead of generic -> NaesbEventProcessCompletion
                //update ProcessEnd timestamp
                _naesbEventProcessUpdateService.Invoke(eventProcessId, new KeyValuePair <string, DateTime>("ProcessEnd", DateTime.Now));

                return(eventProcessId);
            }

            throw new NaesbError
                  {
                      ReasonCode = "101",
                      Value      = "Pipeline/Utility/Cycle naesb event not found."
                  };
        }