Process Request is a generic method that can be called where the conditioning can be done based on a passed in command ID.

This is an example of a process request that is inserting to the reference file FWXR. The Process Request is taken from the SystemBusinessProcess. The Insert is handled by calling the insert method in the Business Process ExcludeSystemReferenceBP and passing the entity to insert which is ExcludeSystemReferenceEnitity.

It is important to include the .am_InitializeWith(inputArgs) when you are changing from one input args to another. In this case, we are converting from a AB_ProcessRequestInputArgs to a AB_InsertInputArgs.  Calling the am_InitializeWith and passing the original imput args will make sure that common properties such as User ID, password and taken are passed to the new input instance.

   public override AB_ProcessRequestReturnArgs am_ProcessRequest(AB_ProcessRequestInputArgs inputArgs)
        {
            var ent = inputArgs.ap_InputEntity as AB_SystemEntity;

            switch (inputArgs.ap_CommandID)
            {

                case SharedEnums.CustomCommandIDs.CheckSingle:
                    try
                    {
                        if (ent == null || ent.ExludeSystemReferenceSystemNumber == null || ent.ExludeSystemReferenceSystemID == null)
                            return new AB_ProcessRequestReturnArgs<AB_SystemEntity>(AB_ReturnCodes.ER.ToString(),
                                new List<AB_Message>()
                                {
                                    new AB_Message("Exclude System Reference Number or Exclude System Reference System ID cannot be null.")
                                }, null);

                        var esrInsertEntity = new ExcludeSystemReferenceEntity()
                        {
                            SystemNumber = ent.ExludeSystemReferenceSystemNumber,
                            SystemID = ent.ExludeSystemReferenceSystemID
                        };

                        var eesrBp = new ExcludeSystemReferenceBP();

                        var ira = eesrBp.am_Insert(new AB_InsertInputArgs<ExcludeSystemReferenceEntity>(esrInsertEntity).am_InitializeWith(inputArgs));


                        return new AB_ProcessRequestReturnArgs<AB_SystemEntity>(ira.ap_ReturnCode, ira.ap_Messages,
                            ira.ap_OutputEntity as AB_SystemEntity);
                    }
                    catch (Exception e)
                    {

                        return new AB_ProcessRequestReturnArgs<AB_SystemEntity>(AB_ReturnCodes.ER.ToString(), new List<AB_Message>() { new AB_Message(e.Message) }, null);
                    }

                default:

                    return base.am_ProcessRequest(inputArgs);
            }
        }