static void Main(string[] args)
        {
            ConsumerApp app = new ConsumerApp();

            if (RunDemo("Learner Personal (Object Service)"))
            {
                try
                {
                    app.RunLearnerPersonalConsumer();
                }
                catch (Exception e)
                {
                    if (log.IsErrorEnabled)
                    {
                        log.Error("Error running the SIF3 demo.\n" + ExceptionUtils.InferErrorResponseMessage(e), e);
                    }
                }
            }
            if (RunDemo("Payload (Functional Service)"))
            {
                try
                {
                    app.RunPayloadConsumer();
                }
                catch (Exception e)
                {
                    if (log.IsErrorEnabled)
                    {
                        log.Error("Error running the SIF3 demo.\n" + ExceptionUtils.InferErrorResponseMessage(e), e);
                    }
                }
            }

            Console.WriteLine("Press any key to continue ...");
            Console.ReadKey();
        }
        void RunLearnerPersonalConsumer()
        {
            LearnerPersonalConsumer learnerPersonalConsumer = new LearnerPersonalConsumer(SettingsManager.ConsumerSettings.ApplicationKey);

            learnerPersonalConsumer.Register();
            if (log.IsInfoEnabled)
            {
                log.Info("Registered the Consumer.");
            }

            try
            {
                // Retrieve Bart Simpson using QBE.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Retrieve Bart Simpson using QBE.");
                }
                LearnerPersonal exampleLearner = new LearnerPersonal {
                    PersonalInformation = new PersonalInformationType
                    {
                        Name = new NameType
                        {
                            FamilyName = "Simpson",
                            GivenName  = "Bart"
                        }
                    }
                };
                IEnumerable <LearnerPersonal> filteredLearners = learnerPersonalConsumer.QueryByExample(exampleLearner);

                foreach (LearnerPersonal learner in filteredLearners)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Filtered learner name is " + learner.PersonalInformation.Name.GivenName + " " + learner.PersonalInformation.Name.FamilyName);
                    }
                }

                // Create a new learner.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Create a new learner.");
                }
                LearnerPersonal newLearner          = ConsumerApp.CreateBruceWayne();
                LearnerPersonal retrievedNewLearner = learnerPersonalConsumer.Create(newLearner);
                if (log.IsInfoEnabled)
                {
                    log.Info("Created new learner " + newLearner.PersonalInformation.Name.GivenName + " " + newLearner.PersonalInformation.Name.FamilyName);
                }

                // Create multiple new learners.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Create multiple new learners.");
                }
                List <LearnerPersonal> newLearners            = CreateLearners(5);
                MultipleCreateResponse multipleCreateResponse = learnerPersonalConsumer.Create(newLearners);
                int count = 0;

                foreach (CreateStatus status in multipleCreateResponse.StatusRecords)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Create status code is " + status.StatusCode);
                    }
                    newLearners[count++].RefId = status.Id;
                }

                // Update multiple learners.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Update multiple learners.");
                }
                foreach (LearnerPersonal learner in newLearners)
                {
                    learner.PersonalInformation.Name.GivenName += "o";
                }

                MultipleUpdateResponse multipleUpdateResponse = learnerPersonalConsumer.Update(newLearners);

                foreach (UpdateStatus status in multipleUpdateResponse.StatusRecords)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Update status code is " + status.StatusCode);
                    }
                }

                // Delete multiple learners.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Delete multiple learners.");
                }
                ICollection <string> refIds = new List <string>();

                foreach (CreateStatus status in multipleCreateResponse.StatusRecords)
                {
                    refIds.Add(status.Id);
                }

                MultipleDeleteResponse multipleDeleteResponse = learnerPersonalConsumer.Delete(refIds);

                foreach (DeleteStatus status in multipleDeleteResponse.StatusRecords)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Delete status code is " + status.StatusCode);
                    }
                }

                // Retrieve all learners from zone "Gov" and context "Curr".
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Retrieve all learners from zone \"Gov\" and context \"Curr\".");
                }
                IEnumerable <LearnerPersonal> learners = learnerPersonalConsumer.Query(zoneId: "Gov", contextId: "Curr");

                foreach (LearnerPersonal learner in learners)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Learner name is " + learner.PersonalInformation.Name.GivenName + " " + learner.PersonalInformation.Name.FamilyName);
                    }
                }

                if (learners.Count() > 1)
                {
                    // Retrieve a single learner.
                    if (log.IsInfoEnabled)
                    {
                        log.Info("*** Retrieve a single learner.");
                    }
                    string          learnerId     = learners.ElementAt(1).RefId;
                    LearnerPersonal secondLearner = learnerPersonalConsumer.Query(learnerId);
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Name of second learner is " + secondLearner.PersonalInformation.Name.GivenName + " " + secondLearner.PersonalInformation.Name.FamilyName);
                    }

                    // Update that learner and confirm.
                    if (log.IsInfoEnabled)
                    {
                        log.Info("*** Update that learner and confirm.");
                    }
                    secondLearner.PersonalInformation.Name.GivenName  = "Homer";
                    secondLearner.PersonalInformation.Name.FamilyName = "Simpson";
                    learnerPersonalConsumer.Update(secondLearner);
                    secondLearner = learnerPersonalConsumer.Query(learnerId);
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Name of second learner has been changed to " + secondLearner.PersonalInformation.Name.GivenName + " " + secondLearner.PersonalInformation.Name.FamilyName);
                    }

                    // Delete that learner and confirm.
                    if (log.IsInfoEnabled)
                    {
                        log.Info("*** Delete that learner and confirm.");
                    }
                    learnerPersonalConsumer.Delete(learnerId);
                    LearnerPersonal deletedLearner = learnerPersonalConsumer.Query(learnerId);
                    bool            learnerDeleted = (deletedLearner == null ? true : false);

                    if (learnerDeleted)
                    {
                        if (log.IsInfoEnabled)
                        {
                            log.Info("Learner " + secondLearner.PersonalInformation.Name.GivenName + " " + secondLearner.PersonalInformation.Name.FamilyName + " was successfully deleted.");
                        }
                    }
                    else
                    {
                        if (log.IsInfoEnabled)
                        {
                            log.Info("Learner " + secondLearner.PersonalInformation.Name.GivenName + " " + secondLearner.PersonalInformation.Name.FamilyName + " was NOT deleted.");
                        }
                    }
                }

                // Retrieve learners based on Teaching Group using Service Paths.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Retrieve learners based on Teaching Group using Service Paths.");
                }
                EqualCondition condition = new EqualCondition()
                {
                    Left = "TeachingGroups", Right = "597ad3fe-47e7-4b2c-b919-a93c564d19d0"
                };
                IList <EqualCondition> conditions = new List <EqualCondition>();
                conditions.Add(condition);
                IEnumerable <LearnerPersonal> teachingGroupLearners = learnerPersonalConsumer.QueryByServicePath(conditions);

                foreach (LearnerPersonal learner in teachingGroupLearners)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Learner name is " + learner.PersonalInformation.Name.GivenName + " " + learner.PersonalInformation.Name.FamilyName);
                    }
                }
            }
            catch (Exception e)
            {
                //if (log.IsInfoEnabled) log.Fatal(e.StackTrace);
                throw new Exception(this.GetType().FullName, e);
            }
            finally
            {
                learnerPersonalConsumer.Unregister();
                if (log.IsInfoEnabled)
                {
                    log.Info("Unregistered the Consumer.");
                }
            }
        }